Accueil > Forum > > > > ressources et API !!!!
ressources et API !!!!
vendredi 15 mars 2002 à 11:44:14 |
ressources et API !!!!

Xs
|
salut ! voila, pour me simplifier la tache, j'utlise les ressources pour creer une boite de dialog (sous VC++ 6). mais j'obtiens, lors de la compilation, le message suivant : 'CreateDialogParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)' voici mon code : #include <windows.h> #include <resource.h> const char g_szClassName[] = "myWindowClass"; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, WndProc); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } je comprend pas !
|
|
vendredi 15 mars 2002 à 12:26:33 |
Re : ressources et API !!!!

Croqmort
|
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc); ça devrai marcher
------------------------------- Réponse au message : -------------------------------
salut ! voila, pour me simplifier la tache, j'utlise les ressources pour creer une boite de dialog (sous VC++ 6).
mais j'obtiens, lors de la compilation, le message suivant :
'CreateDialogParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
voici mon code :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
je comprend pas !
|
|
vendredi 15 mars 2002 à 15:56:00 |
Re : ressources et API !!!!

Xs
|
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc); ça devrai marcher
------------------------------- Réponse au message : -------------------------------
salut ! voila, pour me simplifier la tache, j'utlise les ressources pour creer une boite de dialog (sous VC++ 6).
mais j'obtiens, lors de la compilation, le message suivant :
'CreateDialogParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
voici mon code :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
je comprend pas !
|
|
vendredi 15 mars 2002 à 15:57:24 |
Re : ressources et API !!!!

Xs
|
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc); ça devrai marcher
------------------------------- Réponse au message : -------------------------------
salut ! voila, pour me simplifier la tache, j'utlise les ressources pour creer une boite de dialog (sous VC++ 6).
mais j'obtiens, lors de la compilation, le message suivant :
'CreateDialogParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
voici mon code :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
je comprend pas !
|
|
vendredi 15 mars 2002 à 20:04:55 |
Re : ressources et API !!!!

jcecchi
|
Salut,
A la fin de WndProc au lieu de return 0, essaye de renturn DefWindowProc(hwnd, msg, wParam, lParam); et la ca doit marcher.
------------------------------- Réponse au message : -------------------------------
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
|
|
vendredi 15 mars 2002 à 20:14:05 |
Re : ressources et API !!!!

Xs
|
eh bien non ! j'ai toujours "windows creation failed" !! ca viens du fait que hwnd est trouvé comme NULL alors qu'il est déclaré la ligne au dessue par createdialog.....
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
Salut,
A la fin de WndProc au lieu de return 0, essaye de renturn DefWindowProc(hwnd, msg, wParam, lParam); et la ca doit marcher.
------------------------------- Réponse au message : -------------------------------
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
|
|
vendredi 15 mars 2002 à 20:29:40 |
Re : ressources et API !!!!

jcecchi
|
En fait il faut :
wc.lpfnWndProc = (WNDPROC) WndProc;
------------------------------- Réponse au message : -------------------------------
eh bien non ! j'ai toujours "windows creation failed" !! ca viens du fait que hwnd est trouvé comme NULL alors qu'il est déclaré la ligne au dessue par createdialog.....
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
Salut,
A la fin de WndProc au lieu de return 0, essaye de renturn DefWindowProc(hwnd, msg, wParam, lParam); et la ca doit marcher.
------------------------------- Réponse au message : -------------------------------
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
|
|
vendredi 15 mars 2002 à 22:56:41 |
Re : ressources et API !!!!

Xs
|
tu veux dire que le programme somme ca,doit marcher ? : #include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
eh bien, surprise, ca marche toujours pas !
------------------------------- Réponse au message : -------------------------------
En fait il faut :
wc.lpfnWndProc = (WNDPROC) WndProc;
------------------------------- Réponse au message : -------------------------------
eh bien non ! j'ai toujours "windows creation failed" !! ca viens du fait que hwnd est trouvé comme NULL alors qu'il est déclaré la ligne au dessue par createdialog.....
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
Salut,
A la fin de WndProc au lieu de return 0, essaye de renturn DefWindowProc(hwnd, msg, wParam, lParam); et la ca doit marcher.
------------------------------- Réponse au message : -------------------------------
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
|
|
vendredi 15 mars 2002 à 23:20:24 |
Re : ressources et API !!!!

Croqmort
|
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc); !!!!!!!! comment c horrible :) non mais t'as pas honte !!! j'ai cru que j'allait crever ! donc cet fenetre que tu creer a pour parent elle meme avant meme qu'elle soit creer ? wouaouw m'etonne pas qu'elle delire :) hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)WndProc); c mieux comme ça mais je garanti pas qu'y est pas d'autre erreur :)
------------------------------- Réponse au message : -------------------------------
tu veux dire que le programme somme ca,doit marcher ? : #include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
eh bien, surprise, ca marche toujours pas !
------------------------------- Réponse au message : -------------------------------
En fait il faut :
wc.lpfnWndProc = (WNDPROC) WndProc;
------------------------------- Réponse au message : -------------------------------
eh bien non ! j'ai toujours "windows creation failed" !! ca viens du fait que hwnd est trouvé comme NULL alors qu'il est déclaré la ligne au dessue par createdialog.....
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
Salut,
A la fin de WndProc au lieu de return 0, essaye de renturn DefWindowProc(hwnd, msg, wParam, lParam); et la ca doit marcher.
------------------------------- Réponse au message : -------------------------------
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
|
|
vendredi 15 mars 2002 à 23:44:09 |
Re : ressources et API !!!!

Xs
|
bon, y'a du progres :).... la fenetre s'affiche mais uniquement si j'enleve, dans la dialog, la barre de progression !!
plus fort encore !
si j'attribut une fonction a IDC_ABOUT et IDC_CLOSE , y'a une erreur !
j'obtiens ca :
'IDC_ABOUT' : undeclared identifier case expression not constant 'IDC_CLOSE' : undeclared identifier case expression not constant
ensuite, prochain pb : il m'est impossible de bouger la fenetre : elle reste dans son coin en haut a gauhe !
si quelqu'un arrive a résoudre l'un de mes pb, il est trés fort : a chaque pb resolue :y'a un autre qu'arrive !
------------------------------- Réponse au message : -------------------------------
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc); !!!!!!!! comment c horrible :) non mais t'as pas honte !!! j'ai cru que j'allait crever ! donc cet fenetre que tu creer a pour parent elle meme avant meme qu'elle soit creer ? wouaouw m'etonne pas qu'elle delire :) hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)WndProc); c mieux comme ça mais je garanti pas qu'y est pas d'autre erreur :)
------------------------------- Réponse au message : -------------------------------
tu veux dire que le programme somme ca,doit marcher ? : #include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
eh bien, surprise, ca marche toujours pas !
------------------------------- Réponse au message : -------------------------------
En fait il faut :
wc.lpfnWndProc = (WNDPROC) WndProc;
------------------------------- Réponse au message : -------------------------------
eh bien non ! j'ai toujours "windows creation failed" !! ca viens du fait que hwnd est trouvé comme NULL alors qu'il est déclaré la ligne au dessue par createdialog.....
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error !", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
------------------------------- Réponse au message : -------------------------------
Salut,
A la fin de WndProc au lieu de return 0, essaye de renturn DefWindowProc(hwnd, msg, wParam, lParam); et la ca doit marcher.
------------------------------- Réponse au message : -------------------------------
en fait, il me dit que dans la ligne suivante, hwnd a été utilisé sans etre initaialisé !
hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)WndProc);
------------------------------- Réponse au message : -------------------------------
ca marche effectivement, mais qu'en partie : a present, le prog se compile mais j'obtien la MSGBOX suivante (surprenant !) : "windows creation failed" !!!
pkoi ?
voici mon code changé :
#include <windows.h> #include <resource.h>
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg;
//Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
// Step 2: Creating the Window hwnd = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC) WndProc);
if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; }
ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd);
// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
|
|
Cette discussion est classée dans : int, hwnd, msg, return, wc
Répondre à ce message
Sujets en rapport avec ce message
Fenetre windows en cpp [ par FeelCode ]
bon j'essaye de cree une fenetre windows tout simple mai j'ai un probleme de convertion voir le code plus bas.//**************************************
Lancement d'un programme via un service [ par laetitiavincent ]
Bonjour tout le mondeVoilà mon problème : j'ai fait un petit prog qui, lorsqu'il y a fermeture de session ou de windows, il me lancer une fonction to
Problème graphique avec C [ par le1scorpion1noir ]
salut a tous je peux savoir c'est quoi le meilleur logiciel pour programmer en C puis y t il une différence entre le C et le C++ ? je débute et j ess
WIN32 : Editbox non editable avec une boite de dialogue CHILD [ par Pistol_Pete ]
BonjourVoila mon problème: J'ai créé une fenêtre et dans cette fenêtre j'ai une boite de dialogue avec le style WS_CHILD. Tous mes contrôles de cette
Problème avec fichier manifest [ par Sceyllia ]
Bonjour à tous, J'aurais besoin de l'avis de connaisseurs en c/c++ pour m'éclairer sur le soucis que j'ai depuis quelques semaines concernant ce morc
Problème pour iconiser une application [ par piroman14 ]
Noobinho one again!!Bonjour tout le monde!Je serais très reconnaissant si vous pouviez m'aiguiller pour ce programme.Je souhaite iconiser mon applicat
api window [ par ropars ]
Bonjour<br
interface en c [ par Med2009 ]
salut je suis Mohamed un petit développeur en c et qui désire etre le plus grand développeur dans le monde...
Livres en rapport
|
Derniers Blogs
POUR RAPPEL ! LES SPéCIFICATIONS DES PROTOCOLES OFFICE ET SHAREPOINT SONT DISPONIBLES SUR MSDNPOUR RAPPEL ! LES SPéCIFICATIONS DES PROTOCOLES OFFICE ET SHAREPOINT SONT DISPONIBLES SUR MSDN par neodante
Quelle est le point commun entre : Microsoft il y a 10 ans et Apple aujourd'hui ? Réponse: avoir une politique de protocoles propriétaires et fermés :) Car pour rappel (si si je vous assure c'est important de le rappeler), la majorité des spécifications e...
Cliquez pour lire la suite de l'article par neodante JOYEUX ANNIVERSAIRE NIXJOYEUX ANNIVERSAIRE NIX par ebartsoft
Souhaitons un bon et joyeux anniversaire à notre hôte à tous, Nix.
Je ne le répéterais jamais assez mais sans lui rien ne serait possible. Il défit en permanence les lois de la gravité et comme il le dit si bien, si tu lui fais confiance ça devra...
Cliquez pour lire la suite de l'article par ebartsoft IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc
Forum
MATLAB PROGRAMME MATLAB PROGRAMME par wahab1087
Cliquez pour lire la suite par wahab1087 RGB2GRAYRGB2GRAY par musa18
Cliquez pour lire la suite par musa18
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|