|
You could do that in a few lines of Perl
|
|
|
|
|
Dear All;
I have noticed that once I close a dialog box from the (x) icon -top most right corner-, the dialog is not destroyed. By the way, this dialog is a child of a another main window.
How do i destroy a child window only whenever the user tries to close it from x icon?
Is it enough to add OnClose() event handler to the dialog box? and what should it contain? I have tried the code below but this resulted in the closure of the whole application which i dont want:
<br />
void ChildDlg::OnClose()<br />
{<br />
PostQuitMessage(WM_QUIT);<br />
CDialog::OnClose();<br />
}<br />
Thank you
-- modified at 10:40 Friday 13th April, 2007
llp00na
|
|
|
|
|
Is this a modal or modeless dialog box? Modeless dialogs require some additional thought and consideration.
|
|
|
|
|
I am using a modeless dialog box. Would you also please explain how does it differ when using modal dialog? Thank you
llp00na
|
|
|
|
|
A modal dialog is invoked with DoModal() and it does not return until the dialog is dismissed effectively preventing interaction with the owner.
A modeless is created with Create() and returns immediately leaving the owner AND the dialog open for interaction.
Referencing Jeff Prosise's book I get...
Modeless:
1) Dismiss the dialog using DestroyWindow and not EndDialog()
2) Do not allow CDialog::OnOK or CDialog::OnCancel because both call EndDialog()
3) Instantiated with "new"
4) Override CDialog::PostNCDestroy in the derived dialog class and execute "delete this"
Modal:
1) Dismiss the dialog with EndDialog(). Refer to Mr. Sivakumar's views on modality[^] for additonal info
2) Instantiated on the stack
|
|
|
|
|
Thanx,
Would the following destroy the dialog window?
<br />
void ChildDlg::OnClose()<br />
{<br />
CDialog::OnClose();<br />
}<br />
llp00na
|
|
|
|
|
To the best of my knowledge, no.
However, maybe I'm misunderstanding what you are trying to do.
Either way, my point was to get you to reflect on whether you really needed to use a modeless dialog in the first place because there is some extra work and maintenance, not to mention the need to communicate that whoever "owns" the dialog should not use the pointer once the dialog executes "delete this".
Modeless dialogs are kinda messy at best, imo. From an MFC standpoint, I think I listed most of the pertinent information one should know if they are determined to use modeless dialogs in their app.
I hope that helps.
|
|
|
|
|
Thank you, I am grateful
llp00na
|
|
|
|
|
how to execute exe when system is going to shut down using mfc programming?
|
|
|
|
|
Write an application that catches the WM_QUERYENDSESSION message.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
Have a look here[^] for info about the message.
When you receive the message you can act on it by doing what is supposed to be done when the system shuts down or the user logs off.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I want to run exe when I select Shutdown in start menu
|
|
|
|
|
Hi everybody,
how to overwrite part of an existing file without loosing the remaining information???
ex: file contains info about employees loke empId, salary,Company etc. Now if i want to change company name of a specific employee Id how to achieve it??
|
|
|
|
|
What is the format of the file ?
Me think you will need to load the file in memory, modify the structure internally and write back to the file.
|
|
|
|
|
Hi all,
I have successfully created a notify icon, but how can I create a balloon pop up, when it is created, and let it time out after x amount of time ??
Many Thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thank you for the help _AnShUmAn_
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
HI
I want to get two keys from the keyboard simultaneously , I mean when you press and hold two keys the kbhit() and getch() functions return only the first pressed key .
thanks
|
|
|
|
|
V_shr wrote: I want to get two keys from the keyboard simultaneously
This is impossible since the link from the keyboard is serial.
The only way to detect if two keys are pressed simultaniously is if one of them is a shift-key or similar since that would have an impact on the scan code.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
That is incorrect. The GetAsyncKeyState() function will return the status of any key on the keyboard, up or down.
You can use this macro:
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
to determine if a key is currently being pressed. This will check key state even if your application does not have focus. If you are actually wanting to capture the key presses, you would actually have loop through all of the key codes and check individual status with this method.
Dustin
|
|
|
|
|
Dustin Henry wrote: That is incorrect.
What is incorrect?
Whether the link to the keyboard is serial or not isn't a matter of opinion.
I guess I misinterpreted the OP's problem and what he meant with "simultaneously".
If the question is "how can I determine what keys are being held down", then the answer is "poll the keys with ::GetAsyncKeyState() ", like you suggested.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello,
I use a template class where I would like to overload the operator [ ].
My intention is that not only the instances of the class will call the operator but also the types of the instances.
I have tried the following code. It works but never the operator [] is called.
Please could tell me if is there a solution to use my own overloaded operator with any type like int, float, long etc..
Thanks for your kind answers.
//ClassTest.h
template <class type>
class ClassTest
{
public:
ClassTest(){};
virtual ~ClassTest(){};
type* Date;
inline type& operator[](UINT i_index){return (at(i_index));};
};
main()
{
// test 1
ClassTest <int> theInt;
theInt.Date = new int[10];
theInt.Date[0] =5; //Does not call type& operator[]
//test2
int array[] = {1996,1997,1998}
ClassTest <int> figure;
figure.Date = array;
int xx = figure.Date[1]; //Does not call type& operator[]
}
|
|
|
|
|
You haven't called the [] operator for the template class in either of your examples.
Instead of
theInt.Date[0] =5; // This is using default [] operator to index into the "Date" member.
it should be
theInt[0] = 5;
This will call your operator but it won't compile since you have no "at()" method defined.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi
I am making an application using VC++ now i want to run a bunner
i use the dialog based application .
Can any one tell me how we can do this
mailing me
Yogi
|
|
|
|