Fenetre windows (none)

Résolu
bilaloch Messages postés 556 Date d'inscription lundi 6 octobre 2003 Statut Membre Dernière intervention 31 octobre 2019 - 11 avril 2006 à 13:24
bilaloch Messages postés 556 Date d'inscription lundi 6 octobre 2003 Statut Membre Dernière intervention 31 octobre 2019 - 11 avril 2006 à 14:48
Bonjour tout le monde ,

J'ai un ptit probleme... Je sais creer une fenetre normale avec l'API Windows, mais je voudrais en creer une qui n'a pas de barre au dessus (NONE) et qui s'etend sur tout le bureau, ne laissant que la barre demarrer d'en bas (ptet MAXIMISED).Pourriez vous me donner un exemple pour une telle fenetre. J'espere avoir ete assez clair sur mon probleme .

Merci beaucoup

BILALoch

4 réponses

niketou Messages postés 295 Date d'inscription dimanche 4 mai 2003 Statut Membre Dernière intervention 6 décembre 2010
11 avril 2006 à 13:43
ShowWindow(hWnd, SW_SHOWMAXIMIZED);
3
meech Messages postés 209 Date d'inscription vendredi 11 avril 2003 Statut Membre Dernière intervention 14 août 2007
11 avril 2006 à 14:15
Salut,

Ci-dessous un bout de code complet en C permettant d'afficher une fenetre sans barre de titre. Par contre, je ne me suis pas préoccupé des questions de dimension de cette fenêtre.

Ce qui est vraiment important est en rouge (création de la fenêtre).

Testé avec Dev-C++, facilement adaptable sous Visual C++.

#include <windows.h>


#define IDC_BUTTON_CLOSE 101


/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);


/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";


int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)


{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */





/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);


/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;


/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;


/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
NULL, /* Title Text */
WS_POPUP,
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

HWND oBouton;

oBouton = CreateWindow("button","Fermer",
WS_CHILD|BS_PUSHBUTTON|WS_VISIBLE,
58, 78, 100, 20,
hwnd,
(HMENU)IDC_BUTTON_CLOSE,
GetModuleHandle(NULL),
NULL);




/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);


/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}


/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}



/* This function is called by the Windows function DispatchMessage() */


LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{



switch (message) /* handle the messages */
{
case WM_COMMAND: if (LOWORD(wParam) IDC_BUTTON_CLOSE && HIWORD(wParam) BN_CLICKED)
{
MessageBox(hwnd, "Fermeture de la fenêtre", "Quitter", MB_OK);
PostQuitMessage(0);
}
break;
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}


return 0;
}

En espérant t'avoir un peu aidé.
Ciao.
3
niketou Messages postés 295 Date d'inscription dimanche 4 mai 2003 Statut Membre Dernière intervention 6 décembre 2010
11 avril 2006 à 14:18
en c++:(testé sous vc++)
#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:

break;
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;
static char appName[] = "Ma fenetre";

//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;//CS_HREDRAW | CS_VREDRAW;
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 = appName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONERROR | MB_OK);
return 0;
}

hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
appName,
"Mon titre de fenetre",
WS_THICKFRAME,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 400,
NULL, NULL, hInstance, NULL);

if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error",
MB_ICONERROR | MB_OK);
return 0;
}

ShowWindow(hwnd,SW_SHOWMAXIMIZED);
UpdateWindow(hwnd);

// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return int(Msg.wParam);
}
3
bilaloch Messages postés 556 Date d'inscription lundi 6 octobre 2003 Statut Membre Dernière intervention 31 octobre 2019 1
11 avril 2006 à 14:48
Merci a vous tous

BILALoch
0
Rejoignez-nous