|
|
Thank you for replying so quickly. I intend to call API function GetDC(HANDLE hWnd), but the vc always suppose I want to call MFC's GetDC(). So after comiling, it response like this:error C2660: 'GetDC' : function does not take 1 parameters. How to deal with this tough quesiton? I'll look
forward to hearing from you soon.
Thanks.
Ray
|
|
|
|
|
Precede the call to GetDC() with :: (i.e. ::GetDC(hWnd) ). '::' is the scope resolution operator, allowing you to access functions in the global namespace, even if there is a method with the same name in the current class.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Thank you for you help! I have another question for you(as you are super) Can I get the image of any a window's DC that I want(I can get the hWnd of this window) but without
bringing it to the top of the screen?
Thank you again!
|
|
|
|
|
ray_li wrote:
Can I get the image of any a window's DC that I want
I'm assuming here that you mean what is displayed on the window.
As far as i know this is impossible, because Windows does not store internally the contents of any window that is not currently visible - when they become visible again, it sends a WM_PAINT message to tell it to redraw itself. This is why sometimes if a program is busy and you drag another window over it, it doesn't redraw.
If the window is actually visible, then you might be able to grab the dc (or alternatively grab a DC for the entire desktop), and copy it, but having never tried this myself, i'm not sure if it would work (my gut says yes though, because that is probably how screen capture works).
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
I'm looking for WM_COMMAND with CBN_DROPDOWN. I added a print as follows:
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
debug_printf("message=%08X, wparam=%08X, WM_COMMAND=%08X, WM_NOTIFY=%08X, CBN_DROPDOWN=%08X\n",msg.message,msg.wParam,WM_COMMAND,WM_NOTIFY,CBN_DROPDOWN);
if( !TranslateMDISysAccel( (HWND)m_mdi_frame_interior_window, &msg )
&& !TranslateAccelerator( (HWND)m_mdi_frame_window,
(HACCEL)m_accelerator_table, &msg ) )
{
if( FindTargetWindowAndFilter( msg.hwnd, msg.message, msg.wParam, msg.lParam ) )
continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
I see WM_COMMAND arrive for button clicks but not for open/close transition of combo box menus. A button click printed:
message=000000A0, wparam=00000005, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=000000A0, wparam=00000005, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=000000A1, wparam=00000005, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000111, wparam=000000DC, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000005, wparam=00000000, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000200, wparam=00000000, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=0000000F, wparam=00000000, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
But the combo box open/close only gave:
message=00000201, wparam=00000001, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000200, wparam=00000001, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000202, wparam=00000000, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000200, wparam=00000000, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000201, wparam=00000001, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000200, wparam=00000001, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
message=00000202, wparam=00000000, WM_COMMAND=00000111, WM_NOTIFY=0000004E, CBN_DROPDOWN=00000007
It seems that since I'm printing these messages right at the root message loop, regardless of what WinProc they'd be going to, I'd see them. Does one need to do something special to enable those notifications? The documentation for WM_COMMAND and CBN_DROPDOWN don't indicate anything even remotely to that effect.
|
|
|
|
|
Brian Tietz wrote:
I'm looking for WM_COMMAND with CBN_DROPDOWN
There's no such thing. To respond to the CBN_DROPDOWN message, just add a handler for that notification using ClassWizard.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
It's not a class wizard application, I'm using the SDK directly for this application. WM_COMMAND is getting through at that level for button clicks. It should likewise get through for combo boxes. There's probably some requirement though to enable that behavior. Any help would be appreciated.
|
|
|
|
|
Ah.
Handle the WM_NOTIFY message for the case when its wParam contains your combo box's id. The lParam points to a NMHDR struct whose code member will be CBN_mumble .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Note in the original message though, the log of all messages returned from GetMessage...I was looking for WM_NOTIFY, its value is 4E, and that message wasn't generated either. Only mouse events 200,201,202
|
|
|
|
|
My CDialog derived class has a label that I want to say something in.
Now I am actually spawning this CDialog in my OnInitialUpdate of the View class because before it shows the application UI, thee is a lengthy procedure happening. SO I thought I'd pop up this modeless CDialog with a label saying "Loading........." The label shows up, but its got no writing on it....In the CDialog design I set the caption of the label to "Loading" and for good measure, in its initDialog , also set the WindowText.......
Now in my prj in another function (not OnInitialUpdate) after the UI is fully up and running I have a similar label CDialog coming up which does fine!
What am I doing wrong?
Appreciate your help,
ns
|
|
|
|
|
This might sound silly, but (assuming it's a standard static text widget) ensure that the widget is wide enough to display "Loading.........". To be safe, set the "Simple" style (checkbox in resource editor) to ensure at least part of the overly long text shows.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Nope. Its got something to do with the fcat that the UI isnt up yet.though a CDialog I spawn in OnInitialUpdate right before I do the label CDialog gets created with no problem..........it precedes the showing of the main UI quite happily....
Appreciate your help,
ns
|
|
|
|
|
CLoading * pcLoading = new CLoading;
pcLoading->lblText = "Please wait.........loading data";
pcLoading->Create(IDD_DLGTLOADING, this);
pcLoading->ShowWindow(SW_SHOW);
<code>PopulateSortList();</code>
pcLoading->DestroyWindow();
delete pcLoading;
Appreciate your help,
ns
|
|
|
|
|
The static control's window hasn't yet been created. Override CLoading's OnShowWindow() and set the label's text there (once). For example:
CDialog::OnShowWindow (...);
if (m_bFirstTimeShown) {
m_bFirstTimeShown = false;
SetDlgItemText (IDC_LABEL, "Please wait... loading data");
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Didt like that either..............but thanks for trying...
|
|
|
|
|
If I put a button on this CDialog it doesnt show up either...........
Appreciate your help,
ns
|
|
|
|
|
Wo, man!!! Sumpin' ain't right fer sure!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Well.....heres what I see now. If I dont do destry window, then as s oon as the UI comes up the label gets populated. But I needed it to inform the user to wait for the UI to come up.........and not tell them after its up....ya know?
Appreciate your help,
ns
|
|
|
|
|
Before you do your heavy processing, pump the message queue.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Ah, I see what you're trying to do. I'd use this mechanism:- Your view's
OnInitialUpdate() simply displays the CLoading modal dialog.
CLoading does the actual initialization (by posting a custom WM_COMMAND to itself in it's OnInitDialog() .
- When the initialization completes (in the handler of your fake command),
CLoading simply exits (by calling CDialog::OnCancel() ) and control returns to your view. Imho, this is much easier than using a modeless dialog and having to pump the message queue.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Eh? I'm from Barcelona..........
The stuff I want in the lengthy initialization is all data owned by the view (I might not be understanding your suggestion correctly....). SO if I launch the modal dlg then send a messsage to the view to do the lengthy stuff, then call OnCancel once back in the modal dlg?
I anm trying this now, but not sure if thats what you maent...
Appreciate your help,
ns
|
|
|
|
|
I tried it...this time I dont even see a blank CDialog or anything!!!!
Appreciate your help,
ns
|
|
|
|
|
You know naathing? Sorry, I don't buy that!
You wrote:
SO if I launch the modal dlg then send a messsage to the view to do the lengthy stuff, then call OnCancel once back in the modal dlg?
Not quite. When you launch the modal dialog from the view, give it a pointer to the data that belongs to the view. That way it (the dialog) can happily do all the initialization and if you like, even display progress and allow the user to cancel.
When the initialization completes, the dialog ends itself (by calling CDialog::OnOK() ). If an error occured, it can end itself by calling CDialog::OnOK() . That way the view knows what happened.
It's possible that the view isn't completely setup until after it finishes executing OnInitialUpdate() . If this is the case, just have OnInitialUpdate() post a fake command (IDC_DO_INIT) to itself, and do the modal dialog thing in that command's handler. If the init fails, you can programmatically close the view after displaying an informational message.
Hope this helps.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Well,
The trick you suggested does one good thing. My main UI comes up fast now (blank) since the lengthy processing is delegated to the PosTMessage to itself. Its (the main UI)not active till that postMessage wraps up but at least the user can be reassured that somethings happening. It automatically hourglasses itself ---- so even though I STILL dont have the informing dialog, my purpose is quite well served. An inadvertent workaround.....
So....I guess I am okay with this........but still never saw the cdialog at all!!!
Whats really bizarre is that earlier in OnInitialUpdate I instantiate a vector of modeless bozes and show images in them >These show up fine, as the very first thing!!!!
So its happy to do that, but not to put text in my later CDialogs label.............
Appreciate your help,
ns
|
|
|
|
|