Solved

DialogBoxParam returning error

Posted on 2002-04-24
10
1,097 Views
Last Modified: 2012-06-27
I am getting an error 1400 which is an "Invalid window handle". I have checked and the handle is correct. I just do not know where else to look. It is being called in the MainWndProc. The code below is an outtake from my project. Any help would be greatly appreciated. Thanks in advance.

John Saxon

int WINAPI MainWndProc(HWND hWnd, unsigned message, WPARAM wParam, LPARAM lParam)
{
  DLGPROC lpProcAbout;                  // pointer to the "About" function
  DLGPROC lpDialProc;                           // Pointer to Dial Selections
  DLGPROC lpNavSetup;                       // Pointer to Navigator dialog
  DLGPROC lpCommDlg;                // pointer to the "Network hostname" dialog
  RECT rc;
  GLOBALHANDLE hgMem;
  LPSTR lpData;
  int i,j,sr,er,sc,ec, trow, tcol;    //VT
  DWORD dw ;
  CHAR szBuf[80];
  static HCURSOR hCursor;
  static BOOL bMouseMove;
  POINT ptTemp;

  BOOL bRet;                                            //VT

  switch (message)
  {  
           case EMU_LOGIN:             /* Display login dialog box */
                lpProcAbout = MakeProcInstance(LoginDlg, hInst);
                    //hWnd = 0x081604FA;
                    DialogBoxParam(hInst, MAKEINTRESOURCE(LOGINBOX), hWnd, (DLGPROC)lpProcAbout, (LPARAM)0L);
                    dw = GetLastError();
                    sprintf(szBuf, " failed: GetLastError returned %u\n",dw);
                    MessageBox(NULL, szBuf, "Error", MB_OK);
                    //ExitProcess(dw);
                    FreeProcInstance(lpProcAbout);  
                break;

  }
  return (DefWindowProc(hWnd,message,wParam,lParam));
}
0
Comment
Question by:jsaxon2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6966771
>>I am getting an error 1400 which is an "Invalid window handle".

Why do you know the 'DialogBoxParam()' call failed? You are not checking the return value. 'GetLastError()' will return some arbitrary value if there was no error before. But, if you want to use it, make sure to call 'SetLastError()' first, e.g.


SetLastError ( 0);
DialogBoxParam(hInst, MAKEINTRESOURCE(LOGINBOX), hWnd, (DLGPROC)lpProcAbout, (LPARAM)0L);
dw = GetLastError();

0
 
LVL 3

Author Comment

by:jsaxon2
ID: 6966785
I know it fails because the dialog never displays. I did try your suggestion and am still getting the same error.
0
 
LVL 3

Author Comment

by:jsaxon2
ID: 6966790
Also, I did check the return value prior to using GetLast Error and it also was 1400.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 6966816
OK, let's see then:

Is 'LOGINBOX' a valid resource ID? Where do you get 'hInst' from? Does it work with


DialogBoxParam(hInst, MAKEINTRESOURCE(LOGINBOX), hWnd, (DLGPROC)LoginDlg, (LPARAM)0L);

(The MakeProcInstance function is obsolete)?

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6969554
DialogBox and DialogBoxParam fail whenever there is a child window that can't be created.  This most often occurs when an ActiveX control is involved, but it could be a rich edit control, etc..  

To test to see if this is the problem, create a new dialog that contains only an OK button and try to bring it up instead.  If that works, look at each of the controls in the dialog box that is failing.

-- Dan
0
 
LVL 3

Author Comment

by:jsaxon2
ID: 6972300
It turns out tht the program was using some Borland specific controls that were not valid. That is why the dialogs were not diaplaying.

This is a program was written some years ago by a person that is no longer with the company. Unfortunately there are not many comments in the code. Thanks for your time.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6972402
>>using some Borland specific controls that were not valid.
So the solutuoin was apparently unrelated to any child windows that could not be created...

-- Dan
0
 
LVL 86

Expert Comment

by:jkr
ID: 6972665
Yes, indeed, technically speaking, Dan should have received the points, as he was closest to the solution...
0
 
LVL 3

Author Comment

by:jsaxon2
ID: 6972710
I appologize, but I corrected the problem before I saw Dans post. I am posting points for Dan. Thanks for your help.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6974317
Proof at last!  The crying baby DOES get the milk!  -- Dan
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question