|
myRadioButton.SetCheck (BST_CHECKED); // Use BST_UNCHECKED to uncheck
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Rather than have a bunch of ugly casts, temporary variables, and calls to GetDlgItem() , assign each radio button to a CButton member variable. Then just use the SetChecked() method.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
For non-MFC programming:
BOOL CheckRadioButton(
HWND hDlg, // handle to dialog box
int nIDFirstButton, // identifier of first button in group
int nIDLastButton, // identifier of last button in group
int nIDCheckButton // identifier of button to select
);
or this macro defined in "windowsx.h"
SetCheck(hDlg,nIDCheckButton);
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Neither of the above listed methods appear to work. When I query the button, the correct value shows up, ut it isn't re-drawn correctly. Even after forcing the control/window to re-draw.
|
|
|
|
|
well, found out of you use ShowWindow(FALSE), then change it, then ShowWindow(TRUE) it does re-draw and it works correctly.
|
|
|
|
|
WarChildWTS wrote:
Neither of the above listed methods appear to work.
That's strange!
Both of those methods have been available for at least 15-years (Window 3.1 and above). MFC its self calls the first method internaly, inorder to set/clear a check box (radio button). I've converted 16-bit C-programs to 32-bit programs and this is one, of the many, function calls that has not changed.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I did get it to work. The trick I found was that I had to hide the radio buttons, make the change then show the radio buttons using the ShowWindow function. I don't know why it didn't work otherwise, it should have. It works for the initial setting of the buttons, but it just doesn't seem to re-draw them correctly after that.
|
|
|
|
|
You're correct! It should have worked. It sounds like you have some other problem that you have yet to discover.
In any case maybe you should just try invalidating the radio buttons (or window), instead of hiding and then showing the window. Just a suggestion, since you probably already tried that.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
This is a little difficult to explain. I created a dll in .NET using C# and I need to call this dll from a Visual C++ 6.0 application. I read numerous materials on setting the C# dll up with COM Interop and I think I have it working. Now for the difficult part: when I call the function to launch the UI in the C# dll, it comes up, then I do my thing and close it down. I then go through the functionality again and the dll is called w/ no problems, the form comes up, etc. When I close it down, I will get a GPF. In trying to trace the problem, it returns from my dll, then returns from my function in the 6.0 c++ application, and returns from another function. I cannot discover where the GPF is occurring. Here is a basic outline of my 6.0 c++ function:
void functionname
{
// Initialize COM.
HRESULT hr = CoInitialize(NULL);
// Create the interface pointer.
IManageInterfacePtr pIInterface(__uuidof(ManagerInterface));
// Call the Add method.
pIInterface->LaunchRSSDLL(string, string, string);
pIInterface->Dispose(); <--this is from trying something with the C# dll
pIInterface->Release();
// Uninitialize COM.
CoUninitialize();
}
I have put try/catch inside this function, around the call to this function, inside my C# DLL COM interface, and I still cannot find where the gpf is occurring. This is my first C# dll so be please be patient if I so kind of idiotic in describing this. Any ideas on what I may be missing? Any ideas on what I can look at?
|
|
|
|
|
I found my own answer in this article:
http://www.dotnet247.com/247reference/msgs/35/178790.aspx
I removed the line of code
System.Windows.Forms.Application.EnableVisualStyles()
and all is well.
|
|
|
|
|
I am trying to implement version control on saved objects by using the following:
IMPLEMENT_SERIAL(MyObject, CObject, VERSIONABLE_SCHEMA | 2)
void MyObject::Serialize(CArchive& ar)
{
if (ar.IsLoading()) {
int version = ar.GetObjectSchema();
switch (version){
case 1:
//load first version
break;
case 2:
// load second version
break;
default:
AfxThrowArchiveException(CArchiveException::badSchema, "AppVersion");
break;
}
}
but.. ar.GetObjectSchema(); always returns -1.
I can get the above to work if I add
CObject::Serialize(ar);
ar.SerializeClass(GetRuntimeClass());
so now ar.GetObjectSchema() will return the proper schema
but.. I already have version 1 information on disk w/o these two calls.
Did I mess up? Is there a fix?
Thanks for anyone who can help!
|
|
|
|
|
I usually avoid this overly complicated scheme in the first place and always write out a DWORD to use as my own 'version schema' as the first element of the serialized file. Just increase the DWORD each time you change the version,a nd youc an easily 'switch' on it for handling earlier versions of your files in later versions of your program. As long as you can compensate for the very first version, which did not have this value, you are okay to go on subsequent ones, where you will always write it out.
|
|
|
|
|
I came to same conclusion. It sure looked good in the examples though! Thanks!
|
|
|
|
|
This[^] series of articles may help you brew your own serialization scheme.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks for the link! I am not sure how I missed these. I searched the archive on almost every key word I could think of.
|
|
|
|
|
Sadly, CP's search leaves a lot to be desired. But the quality of the articles and the community more than makes up for it.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
I want to create multithread, each thread read a file, how do write in SDK, write your suggestion.
Thank you.
regards,
Inba.
|
|
|
|
|
inbha wrote:
I want to create multithread...how do write in SDK
Use _beginthread() for this.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
It is better to use IOCP (IO completion ports) for such a task. See CreateFile and ReadFile() in the MSDN library.
John
|
|
|
|
|
Developing application: WinCE, hhp Dolphin9500.
Is there a function to set the keyboard to alphabetic?
|
|
|
|
|
Hi all,
I'm beginning the development of a context menu shell extension on windows 2000 and I have a question. I want to take different actions and build different menu entries depending on what I click, background or file. Which is best: developing two different projects, what will create two different DLLs, or develop only one project and let the ifs and elses treat the differences for me, creating only one DLL? If the second case is the ideal one, how do I differenciate between a file or a background click, for example, in the QueryContextMenu?
Thanks,
Luiz.
|
|
|
|
|
You can set the registry for directory / * file context menus to point to two different GUIDs that
both point back to the same DLL.
So you would have two different COM classes (e.g. CLSID_DirectoryContext & CLSID_FileContext) in your
DLL which would both implement the IContextMenuX, etc interfaces as necessary.
So, both being handled in one DLL is not only possible, it is pretty easy.
Iain.
|
|
|
|
|
Please help me with a segment code which can redirect the output to a file instead of using >> in the commandline. I am using c language.
oam
|
|
|
|
|
Try this:
FILE *file;
file = fopen("C:\\Progrem files\\test.txt","w");
CString output;
for(int i = 0 ; i < 10 ; i++)
{
output.Format("this is test string number %d",i);
fputs(output.GetBuffer(output.GetLenght() + 1),file);
}
fclose(file);
now,if you will open the test.txt file in your C:\Program files - guess what???
Good luck,
Eli
|
|
|
|
|
FILE *file;
E:\process.c(145) : error C2275: 'FILE' : illegal use of this type as an expression
oam
|
|
|
|