|
yes, this is the procedure, i've placed brakepoints in it to make sure it enters it and it does:
BOOL CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return (0L);
}
and the reason why i use it is because i think i have more control over my program, i don't like those embedded things, hope you understand me
|
|
|
|
|
Anonymous wrote:
and the reason why i use it is because i think i have more control over my program,
Imho, it's much easier to build GUIs using MFC. You get a lot of support from the framework.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I agree, but when you can use the Dialog designer with a non-MFC program i think it's better.
|
|
|
|
|
Anonymous wrote:
i think it's better
i've never heard someone using MFC ask why they can't move their dialog...
but, to each his own.
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
My guess is that the move command does not reach the call to DefWindowProc.
If fact, if the command is not handled by your code (ID_FILE_EXIT in this case), then DefWindowProc should be called.
Thus you should add a default in the internal switch that will call DefWindowProc.
But according to MSDN, systems command like SC_MOVE are send as a WM_SYSCOMMAND message so it may be something else...
Philippe Mori
|
|
|
|
|
I already have a default case in my switch statement...:
BOOL CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case IDC_OPENFILE:
OnOpenFile(hWnd);
break;
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
}
break;
case WM_INITDIALOG:
OnInitApp(hWnd);
break;
case WM_DESTROY:
RegSave(hWnd);
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return (0L);
}
i have also made breakpoints so see if the satement is executed, and it is..
|
|
|
|
|
Hey Guys
If i use an instance of a class in a funtion then deallocate it is it deallocated again when the function drops out. I only ask cos i keep getting a close handle again on my file access class at the end of my function even though i have already destructed the instance and haven't created another.
Peter
|
|
|
|
|
if you "new" an object, then the destructor is only called when you "delete" it.
if you allocate the object on the stack, the destructor is called when the object goes out of scope.
one or the other (or you can explicitly call the destructor, but that's something you can't really do without knowing you're doing it)
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
If you store a pointer to class A as member variable in class B, and class B is designed to delete the A object in its own destructor, you should reset the pointer to NULL when you manually delete object A. This will make it clear:
B:: ~B()
{
if (m_ptrA != NULL) {
delete m_ptrA;
}
}
B::someFunction()
{
m_ptrA = new A();
...;
delete m_ptrA;
m_ptrA = NULL;
} /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
No. But if you haven't created your own copy c'tor and assignment operator a HANDLE wrapper class might use the compiler generated versions and then two object might try to release the same resoucrce when they are destructed.
|
|
|
|
|
Hi:
This may be a stupid question.
In a dialog box, a certain function is called when I press 'Add' button. This function adds data to the listbox and then goes through the loop which takes about 15 seconds. The listbox doesn't get repainted until this long procedure is over (in fact, the control disappears from the screen at all during that time).
Is there a way to refresh/repaint the control BEFORE this lengthy loop is called?
Thanks
|
|
|
|
|
UpdateWindow will update the contents. Also, another function for you to be aware of is SetRedraw which allows you to disable drawing for situations where you're doing a lot to the control and don't want the flicker - but instead want a complete redrawing of the control only when finished.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
In addition to Tom's suggestions, you shouldn't be repopulating the entire list box when you add an item. This is a common GUI mistake. Instead, keep the listbox in synch with your data store by simply adding/inserting a single element. This will make your GUI respond faster and appear more professional.
If you must repopulate the list box, show a busy cursor. Use AfxGetApp()->DoWaitCursor() to do this.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi!
You are really taking the things out of context and causing utter confusion to the people who are looking for 'good' suggestions. Please look at a question twice or thrice before posting your suggestion.
Thanks
|
|
|
|
|
Yes, I'm well aware of the original question. What about my suggestion did you find not good or misleading?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I should've read the question the 4th. time. Thanks!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I don't think you will listen the 'real' music even at the n'th time;P
|
|
|
|
|
I have a menu item to exit the application(MDI).
the title on the menu Item is "Exit".
what is the best(safest) way to terminate the application ?
|
|
|
|
|
|
Use the CWinApp::OnAppExit function if you want to mimic exactly how the MFC exits the app
By the way, the best way to figure things like this out is to look at the menu in your default MDI app. You'll see that the Exit menu item has an ID of ID_APP_EXIT.
Then, taking that if you search through the MFC source code (using Find in Files) you'll find the following message map for the CWinApp class.
BEGIN_MESSAGE_MAP(CWinApp, CCmdTarget)
ON_COMMAND(ID_APP_EXIT, OnAppExit)
ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE1, OnUpdateRecentFileMenu)
ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE16, OnOpenRecentFile)
END_MESSAGE_MAP()
This type of peeking into the MFC code is the best way to learn the "correct" way to program your apps.
Cheers,
Tom Archer
Author, Inside C#
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
|
|
|
|
|
I have made a resource file which defines what controls etc. are on my form, but how do i use that Resource on my main window? I know how to use it when creating a new dialog but not with the main window. And, i don't want to use MFC
thanks
|
|
|
|
|
hi,
i keep getting an error saying ": error C2196: case value '1' already used".
is there another way of having an or function in the middle
switch (get_textletter)
{
case 'a' || 'A':
get_textletter=0;
break;
case 'b'|| 'B':
get_textletter=1;
break;
case 'c'|| 'C':
get_textletter=2;
break;
|
|
|
|
|
'a' || 'A' is a logical or operation. Thus, the result is either 0 or 1.
try:
case 'A':
case 'a':
etc...
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
i think you would have to use the ascii values of the various letters instead.
|
|
|
|
|
There is no difference between 97 and 'a'.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|