?
Solved

DialogBoxParam returning error

Posted on 2002-04-24
10
Medium Priority
?
1,118 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 800 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

771 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