×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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.   

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

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.

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

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close