Article View: comp.windows.ms.programmer
Article #2058How to open two windows from one application
From: Quincey Koziol
Date: Fri, 12 Apr 1991 18:10
Date: Fri, 12 Apr 1991 18:10
150 lines
6066 bytes
6066 bytes
Ok, I'm stumped. How does one open two windows from one Windows App? I have
tried so many combinations I'm really getting sick of this problem. Attached
below is the relevant section of my current iteration of the code:
===============================================================================
char far szAppName[] = "SciVis"; /* App. name */
char far szPalName[] = "SciVis_Pal"; /* Name of the palette window */
typedef struct info_node { /* structure for information about the window */
WORD WindowWidth, /* the width and height of the data int the window in pixels */
WindowHeight;
} wind_info;
typedef struct wind_node { /* a structure which contains all the information needed to display a window on the screen */
HPALETTE hWindPal; /* handle to the window's palette */
HANDLE hdibWindow; /* handle to the window's DIB */
HBITMAP hbmWindow; /* handle to the window's BM */
HANDLE hbiWindow; /* handle to the window's BitmapInfo */
} window;
HPALETTE hpalCurrent = NULL;/* Handle to current palette */
HANDLE hdibCurrent = NULL; /* Handle to current memory DIB */
HBITMAP hbmCurrent = NULL; /* Handle to current memory BITMAP */
HANDLE hbiCurrent = NULL; /* Handle to current bitmap info struct */
WORD wBitmapWidth,wBitmapHeight, /* width and height of the bitmap loaded currently */
wDisplayWidth,wDisplayHeight; /* width and height of the bitmap displayed currently */
HWND hWndApp; /* Handle to app. window */
HWND hDebugWnd; /* Handle to the debugging window */
HWND hPaletteWnd; /* Handle to the palette window */
short xScreen, yScreen; /* size of the screen */
short xFrame, yFrame; /* frame around the sizeable window */
short MenuHeight; /* height of the menu bar */
short CaptionHeight; /* height of caption */
/* Styles of app. window */
DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME;
DWORD dwPalStyle = DS_MODALFRAME | WS_OVERLAPPED | DS_NOIDLEMSG | WS_CAPTION | WS_BORDER ;
/****************************************************************************
* *
* FUNCTION : WinMain(HANDLE, HANDLE, LPSTR, int) *
* *
* PURPOSE : Creates the app. window and enters the message loop. *
* *
****************************************************************************/
int PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpszCmdLine;
int nCmdShow;
{
HWND hWnd;
WNDCLASS wndclass;
WNDCLASS palclass;
FARPROC lpProc;
MSG msg;
char ach[40];
hInst = hInstance;
/* default to MEMORY DIB's if XWindows */
bMemoryDIB = WinFlags & WF_PMODE;
/* Initialize clip rectangle */
SetRectEmpty(&rcClip);
/* get a procedure instance for the palette window */
lpProc=MakeProcInstance((FARPROC)PalWndProc,hInst);
if (!hPrevInstance) {
wndclass.style = CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInst, "SHOWICON");
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName = szAppName;
wndclass.lpszClassName = szAppName;
if (!RegisterClass(&wndclass))
return FALSE;
palclass.style = CS_DBLCLKS;
palclass.lpfnWndProc = lpProc;
palclass.cbClsExtra = 0;
palclass.cbWndExtra = 0;
palclass.hInstance = hInstance;
palclass.hIcon = LoadIcon(hInst, "SHOWICON");
palclass.hCursor = LoadCursor(NULL, IDC_ARROW);
palclass.hbrBackground = GetStockObject(BLACK_BRUSH);
palclass.lpszMenuName = szPalName;
palclass.lpszClassName = szPalName;
if (!RegisterClass(&palclass))
return FALSE;
}
/* Save the pointer to the command line */
lstrcpy(achFileName, lpszCmdLine);
xScreen = GetSystemMetrics(SM_CXSCREEN);
yScreen = GetSystemMetrics(SM_CYSCREEN);
xFrame = GetSystemMetrics(SM_CXFRAME);
yFrame = GetSystemMetrics(SM_CYFRAME);
MenuHeight = GetSystemMetrics(SM_CYMENU);
CaptionHeight = GetSystemMetrics(SM_CYCAPTION);
/* Create the app. window */
hWndApp = hWnd =CreateWindow(szAppName,szAppName,dwStyle,CW_USEDEFAULT,
0,xScreen / 2,yScreen / 2,NULL,NULL,hInstance,NULL);
ShowWindow(hWndApp , nCmdShow);
hDebugWnd=CreateDebugWindow(hWndApp); /* Open the debugging window */
hPaletteWnd = CreateWindow(szPalName,szPalName,dwPalStyle,0,
yScreen-(24+CaptionHeight+10),256+2,24+CaptionHeight+8,NULL,NULL,hInstance,NULL);
ErrMsg("Palette Window Handle:%d",(int)hPaletteWnd);
ErrMsg("szPalName=%ld",(long int)szPalName);
ShowWindow(hPaletteWnd , SW_SHOWNORMAL);
/* Enter message loop */
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
FreeProcInstance(lpProc); /* free the procedure instance for the palette */
return msg.wParam;
}
===============================================================================
Somebody please help me, this is really driving me mad!
Quincey Koziol
Programmer
NCSA
koziol@ncsa.uiuc.edu
Technical Details
Message-ID:
<1991Apr12.181046.14531@ux1.cso.uiuc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!yoyodyne!koziolShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!yoyodyne!koziol From: koziol@yoyodyne.ncsa.uiuc.edu (Quincey Koziol) Newsgroups: comp.windows.ms.programmer Subject: How to open two windows from one application Summary: how do you open two windows? Keywords: multiple windows Message-ID: <1991Apr12.181046.14531@ux1.cso.uiuc.edu> Date: 12 Apr 91 18:10:46 GMT Sender: koziol@ncsa.uiuc.edu Organization: National Center for Supercomputing Applications at Urbana Illinois Lines: 150