home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1999 July
/
PCWorld_1999-07_cd.bin
/
602
/
WBPERSON
/
data1.cab
/
SDK_Files
/
C-lang
/
C.L1
/
Appl.cpp
next >
Wrap
C/C++ Source or Header
|
1999-06-09
|
4KB
|
111 lines
/****************************************************************************/
/* appl.cpp - zakladni schema aplikacniho programu ve WinBase602 */
/* (C) Janus Drozd, 1992, 93, 94, 95, 96, 97, 98, 99 */
/* verze: 6.0 (18.1.1999) */
/****************************************************************************/
#include <windows.h>
#include "wbkernel.h"
#include "wbprezen.h"
/* #include "appl.sic" definicni soubor vytvoreny pro tuto aplikaci */
LRESULT WINAPI MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
char jmeno_serveru[] = "WB60";
static char MOJE_APLIKACE[] = "MojeAplikace";
HINSTANCE hInst;
BOOL logged_in = FALSE;
BOOL interf_is_init = FALSE;
BOOL InitApplication(HINSTANCE hInstance) /* registrace tridy */
{ WNDCLASS wc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = MOJE_APLIKACE;
return RegisterClass(&wc) != 0;
}
HWND InitInstance(HINSTANCE hInstance)
{ WBFramePars wbf = { -1, 0 };
return CreateWindow(
MOJE_APLIKACE, "Toto je ramec pro aplikace ve WinBase602",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 640,480,
NULL, 0, hInstance, (void*)&wbf);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{ HWND hMainWindow, hClient; MSG msg;
cd_t my_cd; cdp_t cdp = &my_cd;
cdp_init(cdp);
/* otevreni hlavniho okna aplikace: */
if (!hPrevInstance)
if (!InitApplication(hInstance)) return 1;
hInst=hInstance;
if (!(hMainWindow=InitInstance(hInstance))) return 2;
ShowWindow(hMainWindow, nCmdShow);
UpdateWindow(hMainWindow);
/* napojeni na server */
if (link_kernel(jmeno_serveru, SW_SHOWMINNOACTIVE))
{ DestroyWindow(hMainWindow); return 3; }
if (interf_init((cdp_t)&my_cd, 0))
{ DestroyWindow(hMainWindow); return 4; }
interf_is_init=TRUE;
BringWindowToTop(hMainWindow);
/* prihlaseno se na server: */
if (!Alogin(hMainWindow))
{ DestroyWindow(hMainWindow); return 5; }
logged_in=TRUE;
if (Set_application("PER_AGENDA")) Signalize();
else if (!Open_project("MIN_PLAT")) Signalize();
Info_box("Vzorovß aplikace WinBase602",
"Po odstran∞nφ tohoto okna aplikaci ukonΦφte\nkombinacφ klßves Alt F4");
hClient=GetDlgItem(hMainWindow, CLIENT_ID); // MDI-klient vytvoreny WinBase602
while (GetMessage(&msg, 0,0,0))
if (!TranslateMDISysAccel(hClient, &msg))
{ TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT WINAPI MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ switch (message)
{ case WM_DESTROY:
WinHelp(hWnd, "MYHELP.HLP", HELP_QUIT, 0);
if (logged_in) Logout();
if (interf_is_init) interf_close();
PostQuitMessage(0);
return DefWinBaseFrameProc(hWnd, message, wParam, lParam);
case WM_COMMAND:
switch (wParam)
{ case IDM_HELP_GENERIC:
WinHelp(hWnd, "MYHELP.HLP", HELP_CONTEXT, (DWORD)LOWORD(lParam));
break;
default:
return DefWinBaseFrameProc(hWnd, message, wParam, lParam);
}
break;
case WM_CREATE: // zprava WM_CREATE se predava do DefWinBaseFrameProc
default:
//return DefWindowProc(hWnd, message, wParam, lParam);
return DefWinBaseFrameProc(hWnd, message, wParam, lParam);
}
return 0;
}