Click here to Skip to main content
15,918,624 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Need help to pan client area of a window using win32 api / mfc Pin
Richard MacCutchan20-Aug-12 21:22
mveRichard MacCutchan20-Aug-12 21:22 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Member 935377620-Aug-12 21:59
Member 935377620-Aug-12 21:59 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Richard MacCutchan20-Aug-12 22:34
mveRichard MacCutchan20-Aug-12 22:34 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Richard MacCutchan20-Aug-12 22:36
mveRichard MacCutchan20-Aug-12 22:36 
AnswerRe: Need help to pan client area of a window using win32 api / mfc Pin
Sunil P V20-Aug-12 22:38
Sunil P V20-Aug-12 22:38 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Richard MacCutchan21-Aug-12 0:37
mveRichard MacCutchan21-Aug-12 0:37 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Sunil P V24-Aug-12 1:29
Sunil P V24-Aug-12 1:29 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Member 935377622-Aug-12 21:55
Member 935377622-Aug-12 21:55 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Sunil P V24-Aug-12 1:31
Sunil P V24-Aug-12 1:31 
AnswerRe: Need help to pan client area of a window using win32 api / mfc Pin
pasztorpisti21-Aug-12 4:59
pasztorpisti21-Aug-12 4:59 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
Member 935377622-Aug-12 22:48
Member 935377622-Aug-12 22:48 
GeneralRe: Need help to pan client area of a window using win32 api / mfc Pin
pasztorpisti22-Aug-12 23:07
pasztorpisti22-Aug-12 23:07 
QuestionTrying not to display the "description" part of a tooltip. (MFC) Pin
Maximilien20-Aug-12 5:03
Maximilien20-Aug-12 5:03 
QuestionCan not catch OnKeyup on CListCtrl Pin
_Flaviu20-Aug-12 5:03
_Flaviu20-Aug-12 5:03 
AnswerRe: Can not catch OnKeyup on CListCtrl Pin
Software_Developer20-Aug-12 9:15
Software_Developer20-Aug-12 9:15 
QuestionBITMAPINFOHEADER working in Debug but not in Release Pin
002comp19-Aug-12 21:15
002comp19-Aug-12 21:15 
AnswerRe: BITMAPINFOHEADER working in Debug but not in Release Pin
Endurion_19-Aug-12 22:39
Endurion_19-Aug-12 22:39 
GeneralRe: BITMAPINFOHEADER working in Debug but not in Release Pin
002comp19-Aug-12 22:43
002comp19-Aug-12 22:43 
GeneralRe: BITMAPINFOHEADER working in Debug but not in Release Pin
Endurion_20-Aug-12 5:01
Endurion_20-Aug-12 5:01 
AnswerRe: BITMAPINFOHEADER working in Debug but not in Release [Solved] but need one Suggestion Pin
002comp19-Aug-12 22:41
002comp19-Aug-12 22:41 
AnswerRe: BITMAPINFOHEADER working in Debug but not in Release Pin
CPallini19-Aug-12 23:00
mveCPallini19-Aug-12 23:00 
QuestionModeless Dialog box using win32 API only Pin
csrss19-Aug-12 7:14
csrss19-Aug-12 7:14 
AnswerRe: Modeless Dialog box using win32 API only Pin
pasztorpisti19-Aug-12 12:49
pasztorpisti19-Aug-12 12:49 
First, you probably have a main message loop somewhere that dispatches messages to every window (and dialog), not only to a specified window:
C++
// global variable, it contains the handle of all dialogs
std::vector<HWND> g_Dialogs;

// your main loop somewhere near your main()
MSG msg;
while (::GetMessage(&msg, NULL, 0, 0)) 
{
    // copying the global array because it might be modified during iteration
    // and we iterate over the copy...
    std::vector<HWND> dialogs(g_Dialogs);
    bool was_dialog_message = false;
    for (size_t i=0,e=dialogs.size(); i<e; ++i)
    {
        if (::IsWindow(dialogs[i]) && ::IsDialogMessage(dialogs[i], &msg))
        {
            was_dialog_message = true;
            break;
        }
    }
    if (!was_dialog_message)
    { 
        ::TranslateMessage(&msg); 
        ::DispatchMessage(&msg); 
    }
}


When you want a modeless dialog, you just create it with CreateDialog(), put its handle to g_Dialogs and thats it. You don't have to run a local message loop like with modal messageboxes, especially not with a specified single window handle (m_hWnd). A modeless dialog works almost like a normal window that you created with CreateWindowEx(), you just have to handle it a bit specially with IsDialogMessage(). In a modeless multi-windowed gui program its always enough one message loop - the main message loop pumps the messages for all modeless windows.

EDIT: warning: while you are iterating over the g_Dialogs vector, the contents of the vector might change because you dispatch messages to dialogs that can respond to those messages by creating/deleting dialogs! To avoid bugs caused by this you either use a custom container that can be modified during iteration or solve it somehow else. One good solution can be copying the vector before iteration and iterating on the copied vector, still some HWNDs might become invalid during iteration so before IsDialogMessage() it might be wise to call IsWindow() on the handles.

modified 19-Aug-12 19:12pm.

GeneralRe: Modeless Dialog box using win32 API only Pin
csrss19-Aug-12 21:03
csrss19-Aug-12 21:03 
GeneralRe: Modeless Dialog box using win32 API only Pin
pasztorpisti20-Aug-12 1:49
pasztorpisti20-Aug-12 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.