|
Hi All,
How Can we make a Modeless Dialog Box to Act as Modal Dialog Box??
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
The two kinds of dialogs are created differently. If you're using MFC or ATL, call DoModal() . In the APIs, call DialogBox() instead of CreateDialog()
|
|
|
|
|
I know that but what I want is , how can we make a Modeless Dialog box Once Created to act as Modal dialog box? If I have a dialog and on a button click I am creating a modeless dialog box using create(). Is there a way in which I can make my modeless dialog box to act as modal dialog box?
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
Why are u creating it modalless to make it modal? Just create it in modal way.
CDialogBox* MyDialog;
MyDialog->DoModal ();
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
narayanagvs wrote: Is there a way in which I can make my modeless dialog box to act as modal dialog box?
Actually, no. Unless you 'recreate' (destroy previous and DoModal a new one) your dialog, you cannot turn a modeless into a modal one.
--
=====
Arman
|
|
|
|
|
You can probably do something when your dialog looses the focus. If the focus is going to a window other than your dialog or its children then put the focus back to your dialog but I dont know how well it would work or how it would effect other apps running on the system. Ie its a hack
|
|
|
|
|
You could disable the dialog's parent window, then be sure to re-enable it when your dialog closes. But yeah, this is a hacky idea. Raymond Chen[^] has written some posts about doing manual modality like that, check out his blog.
|
|
|
|
|
Michael Dunn wrote: Raymond Chen[^] has written some posts
"This is like asking for a cheeseburger and then trying to peel every last bit of cheese off the patty to turn it into a plain hamburger."
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
You can disable the parent window.
« Superman »
|
|
|
|
|
narayanagvs wrote: How Can we make a Modeless Dialog Box to Act as Modal Dialog Box??
Is this with MFC? If so, that's already happening.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi,
Suppose there is a program named b.exe, how to program in vc to intercept a message from b.exe?
Thanks in advance,
Cui Sheng
|
|
|
|
|
I assume by message you mean a window message (WM_????? ). Have a look at the SetWindowsHookEx API.
Steve
|
|
|
|
|
|
Hello,
Well, I have created a custom MFC control that derives from CWnd. I have done some work to add double buffering, but now i have a problem. My application sucks up 100% of the CPU.
I have it narrowed down to one line.
void CGameArea::OnPaint()<br />
{<br />
mPlayer->Draw();<br />
<br />
CRect r;<br />
GetClientRect(&r);<br />
<br />
CDC *dc = GetDC();<br />
dc->BitBlt(r.left,r.top,r.right-r.left,r.bottom-r.top,&mBackgroundDC,0,0,SRCCOPY);<br />
ReleaseDC(dc);<br />
}
I am currently not calling the base CWnd OnPaint function because I am doing all the painting myself. Somehow, this is causing the problem.
If I uncomment the base class OnPaint call, my CPU usage goes back to normal, but I get a lot of flicker.
Any idea why NOT calling the CWnd OnPaint would cause 100% CPU usage??
Thanks ahead of time for any help.
-Kevin
-- modified at 8:53 Wednesday 18th July, 2007
|
|
|
|
|
If you don't validate the invalid region of the window then you will continue to receive WM_PAINT
messages until you do so Not good!
This should do it:
::ValidateRect(*this, NULL);
or use a CPaintDC instead of a CDC
//CDC *dc = GetDC();
CPaintDC dc(this);
...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Holy crap, you're the man. You know, I almost tried switching to CPaintDC, but kept telling myself it wouldn't matter.
It all works now. Thanks.
|
|
|
|
|
kalden wrote: mPlayer->Draw();
In addition to what Mark said, I also doubt how you took the DC in the mPlayer->Draw() function;( I am not sure what exactly that draw function does). I suggest you to pass the CPaintDC object to that function and do all the drawing in that DC.
|
|
|
|
|
I am passing a memory DC to a game DLL at initialization. That DLL has the mPlayer->Draw() code and uses GDI+ to draw to the memory DC. The memory DC is then copied to the control DC using Bitblt.
I know there are potential problems with this if the window resizes, but I am not worrying about that at the moment.
|
|
|
|
|
So you stil have problem even after changing the CPaintDC? (Comment out the statement ReleaseDC(dc); also )
|
|
|
|
|
No, it resolved the issue. See my response to Mark's post.
Thanks for your input!
|
|
|
|
|
ho I didn't noticed.
|
|
|
|
|
I am a novice programmer and have been trying to implement a virtual grid control for a tool I am building. The source files I am dealing with are very large binary files and I was told that I need to turn on the virtual mode of the CGridCtrl due to the size of the source files. I was also told that I probably need to use what is called a callback function or OnNotify.
I do have a non-virtual grid control up and running and I am already parsing and displaying data via a worker thread up to a finite number of columns and rows. The moment I turn on virtual mode, the box where my grid should be immediately pops up shows absolutely no cells. It's as if the source file was never even parsed.
I do understand that a virtual grid does not have actual cells defined or something to this effect. This is what I am observing now. I am completely clueless as to how things are done differently when it comes to actually adding data to a virtual cell.
If I must use OnNotify or a callback function, I have been struggling on trying to find useful information on either of these. I do not know exactly what they do or how to use them.
If this helps, I am using VS.NET 2003. Any help would be greatly appreciated.
|
|
|
|
|
Stuck At Zero wrote: If I must use OnNotify or a callback function, I have been struggling on trying to find useful information on either of these. I do not know exactly what they do or how to use them.
Usually they hide that information in the documentation[^]
CWnd::OnNotify The framework calls this member function to inform the parent window of a control that an event has occurred in the control or that the control requires some kind of information.
more[^]
Those little blue underlined parts are called "links". You place your mouse cursor over them and click the "left button"... unless you have a left-handed mouse then you click the "right button".
|
|
|
|
|
Thanks Led. I have an OnNotify function in my code, but I don't know what to do with it. Part of that problem is my confusion over what I need to inside of it as well as feed it. My root problem is the virtual grid. I can turn it on, but after that, I do not know how to add data.
Once I can get that going, I guess I can tackle the OnNotify to try and get the cells to actually display in Virtual mode. For now, I don't even know what to feed an OnNotify at least from glossing over what you referred me to, nor do I know what to do inside of an OnNotify function to get the desired effect.
I also noted that some of the info you pointed me too is VB. I forgot to mention I'm using Visual C++. Sorry for that oversight on my part.
Thanks for the tip on how a hyperlink works.
|
|
|
|
|
Stuck At Zero wrote: For now, I don't even know what to feed an OnNotify
That is specific to each control/message combination. You have to refer to the documentation for the specific control to discover that. In your case it is the CGridControl yes? I haven't worked with it for a few years but you should find lot's of information here on CodeProject about it. Did you look through the CodeProject Articles?
|
|
|
|