Re: Getting error code 6 when creating a dialog

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Wed, 21 Mar 2007 08:15:58 -0700, mpr138
<mpr138@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I am running the following code in CE5.0

CDialog* tempDlg = new CDialogTestDlg();
tempDlg->Create(IDD_DIALOGTEST_DIALOG);
m_pMainWnd = tempDlg;
tempDlg->ShowWindow(SW_SHOW);
DWORD dword = GetLastError();

dword always comes back with an error code of 6 which is invalid handle. The

Call GetLastError only immediately after you call the function you are
trying to check, and only if that function fails. I don't think
ShowWindow ever fails, so calling GetLastError after calling
ShowWindow will be misleading. I suggest the following modification:

CDialog* tempDlg = new CDialogTestDlg();
if (!tempDlg->Create(IDD_DIALOGTEST_DIALOG))
{
DWORD dword = GetLastError();
return;
}
m_pMainWnd = tempDlg;
tempDlg->ShowWindow(SW_SHOW);



window visually appears to be created successfully 80% of the time. The other
20% of the time we are missing fields on the dialog and the application
crashes. Some of the times we notice the dialog is missing fields, we get an
assert on the windows handle, but most of the time we don't. This code is the
same on pocket pc 2003 and windows moblie 5.0 and we do not get the error

I don't have any explanation for the intermittent part. I also don't
see anything in your code snippet that should behave differently on
Pocket PC 2003 and Windows Mobile 5. However, the code in you snippet
might have problems if your menus are set up correctly. Are you using
proper Pocket PC menus?

code 6 from GetLastError. We have also noticed this happen on the Create call
everywhere else in the application. Any help that can be provided would be
greatly appreciated.


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com
.



Relevant Pages

  • Re: Starting a Dial Up connection?
    ... > From the Function I had I recieved this error code "30064771159" how ... C: DWORD InternetDial( ... indicates that a ANSI version (i.e. InternetDialA) will be used on Win9x ... It takes 4 bytes so you can declare it as Integer but all ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Issue with LINEAGENTGROUPENTRY -> Name
    ... > Andreas - Oops, I was using DWORD instead of LONG for Status. ... In TAPI.H error code ... I have authored a tool to dump all TAPI error codes / messages: ...
    (microsoft.public.win32.programmer.tapi)
  • Re: AzMan Access Check
    ... I have got your Win32 version sample project. ... DWORD dwsid, dwdomain; ... printf("ConvertSidToStringSid failed with error code %d", ... Are you sure we need Domain Admin rights to run the code? ...
    (microsoft.public.platformsdk.security)
  • Whats goings-on calling WZCEnumInterfaces return error 1008 under WinXP
    ... It returns error code ... DWORD LoadWZCLibrary() ... if (dwStatus!= ERROR_SUCCESS) ...
    (microsoft.public.win32.programmer.networks)