|
Is there way to create a WM_COMMAND message from within my code?
In constructing a menu under SDI or MDI, one can:
1. Create a menu item.
2. Assign an ID to the menu item
3. Use Wizard to assign the ID to function in a class.
I want to create my own WM_MESSAGE in my own code, assign an ID to it, and use Wizard to assign that ID to a particular function in a class.
Is there a way to do this? Is there a way to do something similar to this?
Thanks.
|
|
|
|
|
Are you looking for RegisterWindowsMessage() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Oliver123 wrote: I want to create my own WM_MESSAGE in my own code, assign an ID to it, and use Wizard to assign that ID to a particular function in a class.
look at WM_APP and WM_USER in your local copy of MSDN or you could refer this article[^] by Mr Joseph M. Newcomer
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I want to get a usb device's firmware serial number.
I know,want there is a new disk was plug into the computer,regedit would report such event:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum
Count would tell me how many disk devices is present.
A sequence item name 0,1,... would hold the device,which are all REG_SZ value.I can get the usb device firmware serial number from the string.
But the problem is,if there are more than one usb disk device present,how should i map the regedit item to its real device(or its disk-letter)?
Thanks.
GOOD LUCK
|
|
|
|
|
Hello,
i was making applition(single document/view application), but i dont know to know attach a control on it, can somebody help me please?
|
|
|
|
|
did you try to create a dynamic control?
for example, CEdit edit1;
edit1.Create(....);
like that.
i donot remember the exact syntax, but if you want it, then i can work it out and guide u.
|
|
|
|
|
Hello,
Can I attach a dialog to Document/view?
is there a way?
|
|
|
|
|
what is your exact question?
1.if you want to create butons on your view, then you can do the same by creating dynamic controls.
2.if you want to load your dialog on clicking any menu item then it is posible using domodal. (i donot think you are not aware of it).
3.by default, if you want your dialog to be displayed in the place of hte view, then i shall work it out and guide you.
but out of the above three, i feel you can prefer the first one.
good luck.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Hello,
what i was going to do is the third part of post
3.by default, if you want your dialog to be displayed in the place of hte view, then i shall work it out and guide you.
I hope we will find out very soon how!!!.
thanks
|
|
|
|
|
How do you want to make them Visual or writting code?
|
|
|
|
|
Hello,
I have a dialog,
i want to attach to Document/view?
is there a way?
|
|
|
|
|
Why you dont use of CFormView instead CView on the CForView you can make your control or insert of Toolbox to Form.
|
|
|
|
|
Hi there. I created an application that on ending it displays:
Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
Now, from my research it said that the successful exit code should be 0. Has anyone had their programs exit with Code 2? Just want to ask so that I would have some clue on where to start finding the cause of this, if this does affect the application in the first place.
thank you!
|
|
|
|
|
It's up to the application to return whatever value is appropriate for
the application.
It's long been conventional to use 0 as a success return value (since it worked
well with DOS batch files, I suppose).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes that was what I was thinking of since in most of the applications I have made, it rarely returns a 0. But I've noticed though that on an application it always returns the same exit code. This maybe a wild goosechase with the exit codes. MSDN doesn't seem to have a proper documentation for them or maybe I'm not poking in the right places. If you do have links about them please give it to me. Anyway, thank you for your help! Gave me confidence on my knowledge about exit codes.
|
|
|
|
|
Llasus wrote: But I've noticed though that on an application it always returns the same exit code.
Is it your application or 3rd party?
If it's yours, you should have control over what's returned
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Nope, I've created them. How do I control the value it returns?
|
|
|
|
|
It depends on what type of application and whether or not it uses the CRT
and/or MFC or other libraries.
Could be main(), WinMain(), CWinApp::ExitInstance(), the exit code in a
WM_QUIT message, etc. Somewhere, the app is exiting
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I see, I'll continue researching on MSDN docs about exit codes and see how it changes depending on my application. If you have links about exit codes though please give it to me. Again, thank you very much for your help!!!
|
|
|
|
|
These are probably the most common places a return value is returned from...
main: Program Startup[^] (Applies to all C/C++ apps)
WinMain Function[^] (Applies to Win32 apps)
CWinApp::ExitInstance[^] (Applies to MFC apps)
CWinApp::Run[^] (Applies to MFC apps - if you've overriden Run(), the returned value can override ExitInstance() return value)
PostQuitMessage Function[^] (Applies to all Windows applications)
Note that many of these propogate up the list depending on the type of application.
For example, in an MFC app, MFC has its own WinMain() and it's all handled by the
CRT main() so you only have to worry about the return value from ExitInstance() or in
rare circumstances, Run().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark. Thanks for your continuous help. I did some experiment and it actually worked by returning exit code 0. Though what I did may not be the right step. Since I don't really edit the ExitInstance() (as I have never used it before) I tried to check on my OnClose() function. By switching the original CDialog::OnClose() with PostQuitMessage(0), it actually returned the proper exit code of 0. But it may not be right since I forced it to return 0. Could you please check on this one?
void CApplicationDlg::OnClose() <br />
{<br />
SomeClass.CleanUp();<br />
<br />
CWnd* ThisDlg;<br />
ThisDlg= GetDlgItem(IDC_LEFTPICBOX);<br />
ThisDlg->ReleaseDC(&GlobalLeftPicDC);<br />
GlobalLeftPicDC.DeleteDC();<br />
ThisDlg= GetDlgItem(IDC_RIGHTPICBOX);<br />
ThisDlg->ReleaseDC(&GlobalRightPicDC);<br />
GlobalRightPicDC.DeleteDC();<br />
<br />
CDialog::OnClose();
}
I may be somehow going away from my problem here but I just want to prove that exit codes doesn't really have an effect on my program. Again, thank you for your help!
|
|
|
|
|
Llasus wrote: Program '[2788] Application.exe: Native' has exited with Code 2 (0x2).
If it's a dialog-based application, are you dismissing the dialog via OK or Cancel?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, I actually removed those two buttons that come as default when creating a new dialog.
|
|
|
|
|
How does the dismissal of the dialog by OK or Cancel relate to the Exit Code 2?
|
|
|
|
|
It relates to it 100%. Try it and see.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|