begin process at 2012 05 28 23:56:25
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

API

 > 

crer "dialog non modal"


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

crer "dialog non modal"

samedi 16 août 2003 à 19:13:08 | crer "dialog non modal"

comfm

Bonjour
Je n'arrive pas à créer une boite de dialogue non modal, c'est à dire celle qui permet d'être tjs affichée et on peut cliquer derriere sans problème...

Le seul truc que j'affiche c'est une fenetre mais elle est modale, donc je perds la main à chaque fois.
Qui peut me modifier mon code svp ?

Merci.



int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;

// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_PAVAGE_1_0, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_PAVAGE_1_0);

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;
}



//
// FONCTION : MyRegisterClass()
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_PAVAGE_1_0);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_PAVAGE_1_0;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}

//
// FONCTION : InitInstance(HANDLE, int)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}

/* la boite de dialogue */
LRESULT CALLBACK dlgproc_outils(HWND hDlg,
UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
switch(uMsg)
{
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_AJOUTER:
// faire break;
}
etc etc etc break;
}
}
break;
default:

break;
}
return 0;
}

//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:

switch (wmId)
{
hDlg = CreateDialog(hInst,MAKEINTRESOURCE(IDD_GLOBALMENU), hWnd, (DLGPROC) dlgproc_outils);
ShowWindow(hDlg, nCmdShow);
UpdateWindow(hDlg);


case IDM_EXIT:
DestroyWindow(hWnd);
break;

case IDM_POINT_AJOUTER:
DialogBox(hInst, (LPCTSTR)IDD_GLOBALMENU, hWnd, (DLGPROC)About);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...


RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;

etc etc etc...



samedi 16 août 2003 à 19:45:05 | Re : crer "dialog non modal"

aardman

Membre Club
Salut,
Pour créer une dialog non modale c'est CreateDialog(..).


-------------------------------
Réponse au message :
-------------------------------

> Bonjour
> Je n'arrive pas à créer une boite de dialogue non modal, c'est à dire celle qui permet d'être tjs affichée et on peut cliquer derriere sans problème...
>
> Le seul truc que j'affiche c'est une fenetre mais elle est modale, donc je perds la main à chaque fois.
> Qui peut me modifier mon code svp ?
>
> Merci.
>
>

>
> int APIENTRY WinMain(HINSTANCE hInstance,
> HINSTANCE hPrevInstance,
> LPSTR lpCmdLine,
> int nCmdShow)
> {
> MSG msg;
> HACCEL hAccelTable;
>
> // Initialize global strings
> LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
> LoadString(hInstance, IDC_PAVAGE_1_0, szWindowClass, MAX_LOADSTRING);
> MyRegisterClass(hInstance);
>
> // Perform application initialization:
> if (!InitInstance (hInstance, nCmdShow))
> {
> return FALSE;
> }
>
> hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_PAVAGE_1_0);
>
> // Main message loop:
> while (GetMessage(&msg, NULL, 0, 0))
> {
> if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
> {
> TranslateMessage(&msg);
> DispatchMessage(&msg);
> }
> }
>
> return msg.wParam;
> }
>
>
>
> //
> // FONCTION : MyRegisterClass()
> ATOM MyRegisterClass(HINSTANCE hInstance)
> {
> WNDCLASSEX wcex;
>
> wcex.cbSize = sizeof(WNDCLASSEX);
>
> wcex.style = CS_HREDRAW | CS_VREDRAW;
> wcex.lpfnWndProc = (WNDPROC)WndProc;
> wcex.cbClsExtra = 0;
> wcex.cbWndExtra = 0;
> wcex.hInstance = hInstance;
> wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_PAVAGE_1_0);
> wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
> wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
> wcex.lpszMenuName = (LPCSTR)IDC_PAVAGE_1_0;
> wcex.lpszClassName = szWindowClass;
> wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
>
> return RegisterClassEx(&wcex);
> }
>
> //
> // FONCTION : InitInstance(HANDLE, int)
> BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
> {
> HWND hWnd;
>
> hInst = hInstance; // Store instance handle in our global variable
>
> hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
> CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
>
> if (!hWnd)
> {
> return FALSE;
> }
>
> ShowWindow(hWnd, nCmdShow);
> UpdateWindow(hWnd);
>
> return TRUE;
> }
>
> /* la boite de dialogue */
> LRESULT CALLBACK dlgproc_outils(HWND hDlg,
> UINT uMsg, WPARAM wParam,
> LPARAM lParam)
> {
> switch(uMsg)
> {
> case WM_COMMAND:
> {
> switch(LOWORD(wParam))
> {
> case IDC_AJOUTER:
> // faire break;
> }
> etc etc etc break;
> }
> }
> break;
> default:
>
> break;
> }
> return 0;
> }
>
> //
> // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
> LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
> int wmId, wmEvent;
> PAINTSTRUCT ps;
> HDC hdc;
> TCHAR szHello[MAX_LOADSTRING];
> LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
>
> switch (message)
> {
> case WM_COMMAND:
> wmId = LOWORD(wParam);
> wmEvent = HIWORD(wParam);
> // Parse the menu selections:
>
> switch (wmId)
> {
> hDlg = CreateDialog(hInst,MAKEINTRESOURCE(IDD_GLOBALMENU), hWnd, (DLGPROC) dlgproc_outils);
> ShowWindow(hDlg, nCmdShow);
> UpdateWindow(hDlg);
>
>
> case IDM_EXIT:
> DestroyWindow(hWnd);
> break;
>
> case IDM_POINT_AJOUTER:
> DialogBox(hInst, (LPCTSTR)IDD_GLOBALMENU, hWnd, (DLGPROC)About);
> break;
> default:
> return DefWindowProc(hWnd, message, wParam, lParam);
> }
> break;
> case WM_PAINT:
> hdc = BeginPaint(hWnd, &ps);
> // TODO: Add any drawing code here...
>
>
> RECT rt;
> GetClientRect(hWnd, &rt);
> DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
> EndPaint(hWnd, &ps);
> break;
>
> etc etc etc...
>
>

>
>


Cette discussion est classée dans : hwnd, msg, wparam, hinstance, wcex


Répondre à ce message

Sujets en rapport avec ce message

PB EditBox [ par SfyLer ] Bonjour à tous !J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je n ouvrir une 2eme fenetre avec editbox et tout et tout, c'est possible? [ par Arnaud16022 ] Hello tout le monde!je voudrais mettre un bouton dans une fenetre (ca c'est facile), mais seulement quand on clique dessus un autre fenetre s'ouvre, a erreur(vc++6) [ par greg4 ] Linking...LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainDebug/fen.exe : fatal error LNK1120: 1 unresolved externalsError execut Pb sur un ptit bout de prog en DirectX.... [ par Haldwin ] Salut a tous....Voila j'ai deux ptits pbs quand je lance cette appli ci-dessous... (VC++)La première est q'une fois sur deux ma variable hWnd apres le Programme ki tourne en arriere plan et qui affiche une message box.. [ par MoDDiB ] Voila je souhaite faire un programme caché qui affiche une message box au bout de 6s mais rien ne marche.. merci de m'aider ^^#include #include // Pro Probleme : error LNK2001: unresolved external symbol... [ par Mr.X ] Tous d'abor bonjour, quand je compile mon programme (visual c++ 6.0), il m'affiche cette erreur, ece que quelqu'un pourrais l'aider ? :Main.obj : erro Gestion des evenements Win32 [ par zibo3 ] J'aimerai créer un événement appuyer sur une touche de type F3 mais cet événement doit se réaliser à chaque fois que j'appuie sur cette touche quelque Erreur incompréhensible et insoluble pour moi.... [ par jb60 ] Voilà, je vais inscrire le source que j'ai tapé (une partie du source plutôt). J'ai l'impression que tout est correct, mais le compilo me fait une err WIN32 Dev-cpp: Le bouton refuse d'afficher le bitmap [ par gekkko ] Bonjour!Je n'arrive pas à faire afficher un bitmap sur un bouton CreateWindow.Le bitmap se charge pourtant bien puisque le .EXE grossit.La compilation bmp dans static [ par Arnaud16022 ] bonjourvoila je veux mettre un bmp dans un static.dans le fichier rc ya:SniperImg BITMAP "C:/sniper.bmp"et dans le main ya (en simplifie)#include LRES


Nos sponsors


Sondage...

Comparez les prix

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,749 sec (3)

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