Bonjour à tous!

Je vous remercie à l'avance de vous pencher sur mon code.
Voilà, je débute en API Win32 et je coince sur deux points:

a) Au lancement de mon programme, j'affiche une belle fenêtre (fichier, options, aide...) et je désire que tout durant l'utilisation du programme, une dialogbox reste dans la zone client, attention, c'est une boîte de dialogue non modale.
Malheureusement, je n'arrive pas à la faire s'afficher.
J'ai testé plusieurs manière de l'afficher, sans succès, la dernière (que vous constaterez plus bas) est de créer et d'afficher la boîte de dialogue lorsque le message WM_PAINT est traîté, sans succès non plus.


b) Je désire utiliser une barre de statut, c'est à dire la barre se trouvant au bas de ma fenêtre principale renseignant des informations à l'utilisateur sur l'option du menu où se trouve sa souris. Malheureusement, mon linker n'aime pas InitCommonControls().

Le code concernant la status bar se trouve commenté.
La dialogbox se trouve dans le message WM_PAINT.

Merci de m'expliquer, si vous le pouvez, ce que je n'ai pas comprit afin que je puisse corriger cela!

Je compile sous VC++



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include <windows.h>
#include <commctrl.h>
#include "winmain.h"

HINSTANCE hinst;

LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL APIENTRY DialogProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
   HWND hwnd;
   MSG msg;
   WNDCLASS wc;
   HMENU hMenu, hSMenuFile, hSMenuOptions, hSMenuHelp;
   HACCEL haccel;
   HANDLE hMutex;

   hMutex = CreateMutex (NULL,FALSE,"beer");               /******************************************/
   if (GetLastError() == ERROR_ALREADY_EXISTS) return 0;   /* We prevent another instance of program */
                                                           /******************************************/
   hinst = hinstance;

   wc.style = 0 ;
   wc.lpfnWndProc = MainWndProc;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = NULL;
   wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(IDI_ICON2));
   wc.hCursor = LoadCursor(NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(2 + COLOR_BTNFACE);
   wc.lpszMenuName =  NULL;
   wc.lpszClassName = "MainWindow";

   if(!RegisterClass(&wc)) return FALSE;
   
   /********************\
   * We create our menu *
   \********************/
   hSMenuFile = CreateMenu();
   AppendMenu(hSMenuFile, MF_STRING, IDM_SAVEALL, "Enregistrer tout\tCtrl+S");
   AppendMenu(hSMenuFile, MF_SEPARATOR, 0, NULL);
   AppendMenu(hSMenuFile, MF_STRING, IDM_QUIT, "Quitter\tAlt+F4");

   hSMenuOptions = CreateMenu();
   AppendMenu(hSMenuOptions, MF_STRING, IDM_CONFIG, "Configuration\tCtrl+P");

   hSMenuHelp = CreateMenu();
   AppendMenu(hSMenuHelp, MF_STRING, IDM_HELP, "Aide\tF1");
   AppendMenu(hSMenuHelp, MF_SEPARATOR, 0, NULL);
   AppendMenu(hSMenuHelp, MF_STRING, IDM_ABOUT, "A propos de "PROGNAME);

   hMenu = CreateMenu();
   AppendMenu(hMenu, MF_POPUP, (UINT)hSMenuFile,"Fichier");
   AppendMenu(hMenu, MF_POPUP, (UINT)hSMenuOptions,"Options");
   AppendMenu(hMenu, MF_POPUP, (UINT)hSMenuHelp, "?");

   /**********************\
   * We create our window *
   \**********************/
   hwnd = CreateWindow("MainWindow", PROGNAME" "PROGVERSION, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenu, hinstance, NULL);
   if (!hwnd) return FALSE;

   ShowWindow(hwnd, nCmdShow);
   UpdateWindow(hwnd);

   haccel = LoadAccelerators(hinstance, "KeyboardAccelerators"); // Loading of keyboard accelerators

   while (GetMessage(&msg, NULL, 0, 0))
   {
      if (!TranslateAccelerator(hwnd, haccel, &msg))
      {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
   }
   return msg.wParam;
}

/******************************************************************************/
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   //static HWND hstatusbar;
   static HWND hdialog;

   switch (uMsg)
   {
      HDC hDC; 
      PAINTSTRUCT paintst; 
      case WM_CREATE:
           {
              /* InitCommonControls();
               hstatusbar = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", hwnd, -1);*/
              return 0;
           }

      case WM_CLOSE:
         DestroyWindow(hwnd);
         return 0;

      case WM_COMMAND:
         if(LOWORD(wParam) == IDM_QUIT)
            PostMessage(hwnd, WM_CLOSE,0,0);

         if(LOWORD(wParam) == IDM_HELP)
            MessageBox(hwnd,"Not implemented yet...\t","Aide",MB_ICONINFORMATION);

         if(LOWORD(wParam) == IDM_ABOUT)
            DialogBox(hinst, "IDD_DIALOG1" , hwnd, (DLGPROC)DialogProc);
            
      case WM_PAINT:
         hDC=BeginPaint(hwnd,&paintst);
         /************************************************************************************* F*c*ing DialogBox...*/
         if(hdialog) ShowWindow(hdialog,SW_SHOWNORMAL);
         else hdialog = CreateDialog(hinst,"IDD_DIALOG1",hwnd,(DLGPROC)DialogProc);
         /**********************************************************************************************************/
         EndPaint(hwnd,&paintst);
         return 0;

      /*case WM_MENUSELECT:
         {
            if (lParam == (LONG)GetMenu(hwnd))
            {
               if(LOWORD(wParam) == 0)
                  SendMessage(hstatusbar, SB_SETTEXT, 0, (LONG)"Menu Fichier");
               if(LOWORD(wParam) == 1)
                  SendMessage(hstatusbar, SB_SETTEXT, 0, (LONG)"Menu Aide");
            }
            else
            {
               if(LOWORD(wParam) == IDM_QUIT)
                  SendMessage(hstatusbar, SB_SETTEXT, 0,(LONG)"Quitter "PROGNAME".");
               if(LOWORD(wParam) == IDM_SAVEALL)
                  SendMessage(hstatusbar, SB_SETTEXT, 0,(LONG)"Sauver les modifications.");
               if(LOWORD(wParam) == IDM_CONFIG)
                  SendMessage(hstatusbar, SB_SETTEXT, 0,(LONG)"Modifier les paramètres de "PROGNAME".");
               if(LOWORD(wParam) == IDM_ABOUT)
                  SendMessage(hstatusbar, SB_SETTEXT, 0,(LONG)"A propos de "PROGNAME".");
            }
            return 0;
          }*/

       case WM_EXITMENULOOP:
            //SendMessage(hstatusbar, SB_SETTEXT, 0, (LONG)"Texte");
            return 0;

      /*case WM_SIZE:
         {
            RECT sbRect;
            UINT sbheight;
            GetWindowRect(hstatusbar, &sbRect);
            sbheight = sbRect.bottom - sbRect.top;
            MoveWindow(hstatusbar, 0, HIWORD(lParam)-sbheight, LOWORD(lParam),sbheight, TRUE);
            return 0;
          }*/
            
      case WM_DESTROY:
         PostQuitMessage(0);
         return 0;

      default:
         return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
}


BOOL APIENTRY DialogProc(HWND hdialog,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
   switch (uMsg)
   {
      case WM_INITDIALOG:
         return TRUE;
      
      case WM_COMMAND:
         if (LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDOK)
            {
               EndDialog(hdialog,0);
               return TRUE;
            }

      default:
         return FALSE;
   }
}
--------------------Configuration: projet - Win32 Debug--------------------
Linking...
winmain.obj : error LNK2001: unresolved external symbol __imp__CreateStatusWindowA@16
winmain.obj : error LNK2001: unresolved external symbol __imp__InitCommonControls@0
Debug/projet.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

projet.exe - 3 error(s), 0 warning(s)

Merci beaucoup à vous.


Cordialement,