• 0
Sign in to follow this  
Ricardo Soares

Menu Em C

Question

Queria saber se alguém pode me dizer como criar menus para programas com interface Windows. Já consigo criar a janela principal mas nada além disso.

Este é o codigo da janela principal:

#include <windows.h>

LRESULT CALLBACK ProcJan (HWND, UINT, WPARAM, LPARAM);

char szNomeAplic[] = "Principal";

int WINAPI WinMain (HINSTANCE hCopia, HINSTANCE hCopiaAnt, LPSTR szLinhaCmd, int iCmdMostrar)

{

HWND hjan;

MSG msg;

WNDCLASS classejan;

classejan.style =CS_HREDRAW | CS_VREDRAW;

classejan.lpfnWndProc =ProcJan;

classejan.cbClsExtra =0;

classejan.cbWndExtra =0;

classejan.hInstance =hCopia;

classejan.hIcon =LoadIcon (NULL, IDI_APPLICATION);

classejan.hCursor =LoadCursor (NULL, IDC_ARROW);

classejan.hbrBackground =GetStockObject (1);

classejan.lpszMenuName =NULL;

classejan.lpszClassName =szNomeAplic;

if (!RegisterClass (&classejan)) return 0;

hjan = CreateWindow (szNomeAplic, "Primeira Janela", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, HWND_DESKTOP, NULL, hCopia, NULL);

ShowWindow (hjan, iCmdMostrar);

UpdateWindow (hjan);

while (GetMessage (&msg, NULL, 0, 0))

{

TranslateMessage (&msg);

DispatchMessage (&msg);

}

return msg.wParam;

}

LRESULT CALLBACK ProcJan (HWND hjan, UINT iMsg, WPARAM wParam, LPARAM lParam)

{

switch (iMsg)

{

case WM_DESTROY:

PostQuitMessage (0);

return 0;

}

return DefWindowProc (hjan, iMsg, wParam, lParam);

}

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this