Bonsoir à tous,
j'ai encore un soucis lié à la suppression de l'utilisation de la CRT, en indiquant un point d'entrée perso au linker.
Je travaille sous XP et VS 2003, et lorsque je ferme mon exe compilé avec l'option /ENTRY, celui-ci reste en mémoire, je dois le fermer avec Ctrl+Alt+Supp, or sans cette dite option, tout fonctionne...
Voici le code incriminé :
#define _WIN32_WINNT 0x0500
#include <windows.h>
#define IDM_OPEN 40001
HINSTANCE hInst;
HWND hMain, hOpen;
char szFile[MAX_PATH];
char *szAppName = "Test";
int dlgSelectBitmap(HWND hOwner)
{
OPENFILENAME ofn;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hInstance = 0; ofn.hwndOwner = hOwner;
ofn.lpstrFilter = "BITMAP(*.bmp)\0*.bmp\0\0";
ofn.lpstrFile = szFile;
ofn.lpstrCustomFilter = ofn.lpstrFileTitle = 0;
ofn.nFileExtension = ofn.nFileOffset = 0;
ofn.lCustData = ofn.dwReserved = 0;
ofn.lpTemplateName = ofn.lpstrInitialDir = ofn.lpstrDefExt = 0;
ofn.lpfnHook = 0; ofn.pvReserved = 0;
ofn.nMaxCustFilter = ofn.nMaxFileTitle = 0;
ofn.FlagsEx = 0;
ofn.nFilterIndex = 1; ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = "Ouvrir un bitmap";
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
szFile[0] = 0;
return GetOpenFileName(&ofn);
}
LRESULT CALLBACK AppWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_CREATE:
hOpen = CreateWindow("BUTTON", "Ouvrir", WS_CHILD | WS_VISIBLE,
8, 8, 100, 30, hWnd, (HMENU)IDM_OPEN, hInst, 0);
return 0;
case WM_COMMAND:
if(LOWORD(wParam) == IDM_OPEN)
dlgSelectBitmap(hWnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0); return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int InitInstance()
{
WNDCLASSEX wclsx;
wclsx.cbSize = sizeof(WNDCLASSEX);
wclsx.style = 0;
wclsx.lpfnWndProc = AppWndProc;
wclsx.cbClsExtra = wclsx.cbWndExtra = 0;
wclsx.hInstance = hInst;
wclsx.hIcon = LoadIcon(0, IDI_APPLICATION);
wclsx.hCursor = LoadCursor(0, IDC_ARROW);
wclsx.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wclsx.lpszMenuName = 0;
wclsx.lpszClassName = szAppName;
wclsx.hIconSm = 0;
if(!RegisterClassEx(&wclsx)) return 0;
hMain = CreateWindowEx(0, szAppName, szAppName, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInst, 0);
return (hMain != 0);
}
#pragma comment(linker, "/entry:myWinMain")
int __stdcall myWinMain()
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int lpCmdShow)
{
MSG msg;
hInst = GetModuleHandle(0);
if(!InitInstance()) return 0;
ShowWindow(hMain, SW_SHOW);
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
Cela fait quelque temps que je me casse la tête à résoudre ce problème sans succès...
Ciao
Urgo