begin process at 2012 05 29 13:10:34
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

API

 > 

ressources et API !!!!


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

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;
}







1 2

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...


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,967 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales