Estoy intentando crear una ventana principal y dentro de ella otra que muestre cierta información como botones e imágenes, y ya he llegado a crear la ventana el menú y la segunda ventana pero no se que pasa pero no la muestra, podríais ayudarme.
el cpp es el siguiente:
Código:
#include <windows.h>
#include <iostream>
#include <tlhelp32.h>
#include <string>
#include "CHSoft.h"
#include "procesos.h"
using namespace std;
LRESULT CALLBACK WinPro (HWND, UINT , WPARAM, LPARAM);
LRESULT CALLBACK WinPr2 (HWND, UINT , WPARAM, LPARAM);
void InsertarMenu(HWND);
void Inicio(HWND);
bool exists(CHAR* fname);
bool ProcessRunning( const char* name );
long TSAY();
void tema();
int CreVenHij();
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND oDlgVen;
HWND oVentPrinc;
MSG msg;
WNDCLASSEX wincl;
wincl.hInstance = hInstance;
wincl.lpszClassName = "Principal";
wincl.lpfnWndProc = WinPro;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (hInstance, "CHSIcono");
wincl.hIconSm = LoadIcon (hInstance, "CHSIcono");
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(150,150,150));
if(!RegisterClassEx(&wincl)) return 0;
oVentPrinc = CreateWindowEx(
0,
"Principal",
wtex001,
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL | WS_MAXIMIZE,
CW_USEDEFAULT,
CW_USEDEFAULT,
600,
400,
HWND_DESKTOP,
NULL,
hInstance,
NULL
);
Inicio(oVentPrinc);
ShowWindow(oVentPrinc, 3);
InsertarMenu(oVentPrinc);
int CreVenHij();
ShowWindow (oDlgVen, 5);
while(TRUE == GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinPro(HWND oVentPrinc, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case CYEENT:
MessageBox(oVentPrinc, wtex001, wtex022, MB_OK);
break;
case CYEMAN:
MessageBox(oVentPrinc, wtex002, wtex023, MB_OK);
break;
case CYELIC:
MessageBox(oVentPrinc, wtex003, wtex024, MB_OK);
break;
case CYEDEM:
MessageBox(oVentPrinc, wtex004, wtex025, MB_OK);
break;
case CYERES:
MessageBox(oVentPrinc, wtex005, wtex026, MB_OK);
break;
case NYSENT:
MessageBox(oVentPrinc, wtex006, wtex027, MB_OK);
break;
case NYSMAN:
MessageBox(oVentPrinc, wtex007, wtex028, MB_OK);
break;
case NYSLIC:
MessageBox(oVentPrinc, wtex008, wtex029, MB_OK);
break;
case NYSDEM:
MessageBox(oVentPrinc, wtex009, wtex030, MB_OK);
break;
case NYSRES:
MessageBox(oVentPrinc, wtex010, wtex031, MB_OK);
break;
case FYVENT:
MessageBox(oVentPrinc, wtex011, wtex032, MB_OK);
break;
case FYVMAN:
MessageBox(oVentPrinc, wtex012, wtex033, MB_OK);
break;
case FYVLIC:
MessageBox(oVentPrinc, wtex013, wtex034, MB_OK);
break;
case FYVDEM:
MessageBox(oVentPrinc, wtex014, wtex035, MB_OK);
break;
case FYVRES:
MessageBox(oVentPrinc, wtex015, wtex036, MB_OK);
break;
case PAGWEB:
MessageBox(oVentPrinc, wtex016, wtex037, MB_OK);
break;
case LICENC:
MessageBox(oVentPrinc, wtex017, wtex038, MB_OK);
break;
case COMUNI:
MessageBox(oVentPrinc, wtex018, wtex039, MB_OK);
break;
case CONSOL:
MessageBox(oVentPrinc, wtex019, wtex040, MB_OK);
break;
case AYUPRO:
MessageBox(oVentPrinc, wtex020, wtex041, MB_OK);
break;
case SALPRO:
MessageBox(oVentPrinc, wtex021, wtex042, MB_OK);
PostQuitMessage(0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(oVentPrinc, msg, wParam, lParam);
case WM_SIZE:
{
RECT rWindow;
GetWindowRect( oVentPrinc, &rWindow );
int nHt = rWindow.right - rWindow.left;
int nWi = rWindow.bottom - rWindow.top;
if ((nHt > (1200*TamPan)) | (nWi >= (800*TamPan)))
ShowScrollBar(oVentPrinc, SB_BOTH, FALSE);
else
ShowScrollBar(oVentPrinc, SB_BOTH, TRUE);
}
}
return 0;
}
int CreVenHij()
{
MSG msg2;
HWND oDlgVen;
HWND oVentPrinc;
WNDCLASSEX wincl2;
HINSTANCE hInstanc2;
wincl2.hInstance = hInstanc2;
wincl2.lpszClassName = "Ventana Hija";
wincl2.lpfnWndProc = WinPr2;
wincl2.style = CS_DBLCLKS;
wincl2.cbSize = sizeof (WNDCLASSEX);
wincl2.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl2.lpszMenuName = NULL;
wincl2.cbClsExtra = 0;
wincl2.cbWndExtra = 0;
wincl2.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(250,250,150));
if(!RegisterClassEx(&wincl2)) return 0;
oDlgVen = CreateWindowEx ( 0,
"Hija",
"Ventana Hija",
WS_CHILD | WS_POPUP,
0*TamPan,
0*TamPan,
600*TamPan,
800*TamPan,
oVentPrinc,
NULL,
hInstanc2,
NULL);
while(TRUE == GetMessage(&msg2, NULL, 0, 0))
{
TranslateMessage(&msg2);
DispatchMessage(&msg2);
}
return msg2.wParam;
}
LRESULT CALLBACK WinPr2(HWND oDlgVen, UINT msg2, WPARAM wParam, LPARAM lParam)
{
switch (msg2)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(oDlgVen, msg2, wParam, lParam);
}
return 0;
}
void InsertarMenu(HWND oVentPrinc)
{
HMENU hMenu01, hMenu02, hMenu03, hMenu04;
hMenu01 = CreateMenu();
hMenu02 = CreateMenu();
hMenu03 = CreateMenu();
hMenu04 = CreateMenu();
switch (TipCyE)
{
case 1:
AppendMenu(hMenu02, MF_STRING, CYEENT, wtex015);
AppendMenu(hMenu02, MF_STRING, CYEMAN, wtex018);
AppendMenu(hMenu02, MF_STRING, CYELIC, wtex019);
break;
case 2:
AppendMenu(hMenu02, MF_STRING, CYEDEM, wtex039);
break;
case 3:
AppendMenu(hMenu02, MF_STRING, CYEDEM, wtex039);
AppendMenu(hMenu02, MF_STRING, CYERES, wtex048);
break;
}
switch (TipNyS)
{
case 1:
AppendMenu(hMenu03, MF_STRING, NYSENT, wtex015);
AppendMenu(hMenu03, MF_STRING, NYSMAN, wtex018);
AppendMenu(hMenu03, MF_STRING, NYSLIC, wtex019);
break;
case 2:
AppendMenu(hMenu03, MF_STRING, NYSDEM, wtex040);
break;
case 3:
AppendMenu(hMenu03, MF_STRING, NYSDEM, wtex040);
AppendMenu(hMenu03, MF_STRING, NYSRES, wtex048);
break;
}
switch (TipFyV)
{
case 1:
AppendMenu(hMenu04, MF_STRING, FYVENT, wtex015);
AppendMenu(hMenu04, MF_STRING, FYVMAN, wtex018);
AppendMenu(hMenu04, MF_STRING, FYVLIC, wtex019);
break;
case 2:
AppendMenu(hMenu04, MF_STRING, FYVDEM, wtex041);
break;
case 3:
AppendMenu(hMenu04, MF_STRING, FYVDEM, wtex041);
AppendMenu(hMenu04, MF_STRING, FYVRES, wtex048);
break;
}
AppendMenu(hMenu01, MF_STRING | MF_POPUP, (UINT)hMenu02, wtex002);
AppendMenu(hMenu01, MF_STRING | MF_POPUP, (UINT)hMenu03, wtex003);
AppendMenu(hMenu01, MF_STRING | MF_POPUP, (UINT)hMenu04, wtex004);
AppendMenu(hMenu01, MF_STRING , PAGWEB , wtex008);
AppendMenu(hMenu01, MF_STRING , LICENC , wtex009);
AppendMenu(hMenu01, MF_STRING , COMUNI , wtex010);
AppendMenu(hMenu01, MF_STRING , CONSOL , wtex011);
AppendMenu(hMenu01, MF_STRING , AYUPRO , wtex012);
AppendMenu(hMenu01, MF_STRING , SALPRO , wtex013);
SetMenu (oVentPrinc, hMenu01);
}
void Inicio(HWND oVentPrinc)
{
if (exists("CHSoft2.exe"))
{
PostQuitMessage(0);
ShellExecute(GetDesktopWindow(), "open", "cambio.bat", NULL, NULL, SW_SHOWNORMAL);
}
else
{
if (ProcessRunning("CHSoft.exe"))
PostQuitMessage(0);
else
{
if (exists("cyew32.exe"))
TipCyE = 1;
else
{
if (exists("cyew32.res"))
TipCyE = 3;
else
TipCyE = 2;
}
if (exists("nysw32.exe"))
TipNyS = 1;
else
{
if (exists("nysw32.res"))
TipNyS = 3;
else
TipNyS = 2;
}
if (exists("fyvw32.exe"))
TipFyV = 1;
else
{
if (exists("fyvw32.res"))
TipFyV = 3;
else
TipFyV = 2;
}
if ((ych / 800) < (xch / 1280))
TamPan = ych / 800;
else
TamPan = xch / 1280;
Tamlet = 18 * TamPan;
OSVERSIONINFO osv = { sizeof(OSVERSIONINFO) };
LPTSTR szFont = TEXT("Times New Roman");
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT && osv.dwMajorVersion >= 5)
{
szFont = TEXT("SEGOE UI");
}
oFont = CreateFont(Tamlet , 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, szFont);
oFon2 = CreateFont(Tamlet , 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, szFont);
oFon3 = CreateFont(Tamlet+3, 0, 0, 0, FW_BOLD , FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, szFont);
}
}
}
bool exists(CHAR* fname)
{
if(INVALID_FILE_ATTRIBUTES == GetFileAttributes(fname) && GetLastError()==ERROR_FILE_NOT_FOUND)
return false;
return true;
}
bool ProcessRunning( const char* name )
{
HANDLE SnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
const char* siono = "N";
if( SnapShot == INVALID_HANDLE_VALUE )
return false;
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof( PROCESSENTRY32 );
if( !Process32First( SnapShot, &procEntry ) )
return false;
do
{
if( strcmp( procEntry.szExeFile, name ) == 0 )
{
if (siono == "N")
{
siono = "S";
}
else
return true;
}
}
while( Process32Next( SnapShot, &procEntry ) );
return false;
};
Gracias.
Carlos.