Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32 C creating a second window in an app (right place?)

Status
Not open for further replies.

JJSRich

MIS
Dec 4, 2008
59
GB
This may be the wrong forum for this, if it is, point me in the right direction.

Here is a section of code that is giving me hassle.

Code:
extern HINSTANCE    hInst;                    // This instance
extern HWND         hWndMain;                 // Handle to Drawing window

BOOL MyFunc(void)
{
BOOL      fStatus;
BOOL    fOkay;
int       iStatus;
int       iDebug;           // Debug output flag
char      szAppName[] = "Viewer";
HWND      hwnd;                //Window handle
MSG    msg;
WNDCLASS    wndclass;
HDC          hdc;                // Window DC
DOCINFO   di;               // Document data
HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);

wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor=LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName=szAppName;
wndclass.lpszClassName = szAppName;

  hwnd = CreateWindow(szAppName,TEXT("Viewer"),
        WS_OVERLAPPEDWINDOW,         //dwStyle
      CW_USEDEFAULT,             //x
      CW_USEDEFAULT,             //y
      CW_USEDEFAULT,             //nWidth
      CW_USEDEFAULT,             //nHeight
      NULL,
      NULL,
      hInstance,
      NULL);

  ShowWindow(hwnd,SW_SHOWNORMAL);
  UpdateWindow(hwnd);
fOkay = 1; //forcing it for debugging
return(fOkay);
}

This is an existing project, that already hs a winmain, and a primary window. What I am trying to do is create another window to interact with. Thus far, my efforts have been futile.
 
Don't quite understand the problem. Do you want

1) To create 2 windows apps to interact with each other
2) Two windows in the same app, both of which are non-modal so they can interact with each other
3) A 2nd window in a specified position
4) None of the above but you're going to tell us what you really want.
 
Strike that, sory. I've made more progress. All I require now, is to get the HWND of the newly created window. What appears to be happening, is somewhere along the line, the window handle for my program's main window is being dereferenced.

Basically, the program has one window with multiple dialog boxes, opened on demand. I am now wanting to create a second window on demand that gets written to in much the same way as we write to a printer device context. It just shows information, but requires drawings, greek characters, and equatios that I don't think a standard dialog box can do.

So far, it is working quite well, except for the hair pulling and dereferencing as mentioned above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top