1. window creation

I get this:

Class "Window Class" registered successfully   --generated after 
RegisterClassA function
dwExStyle = 0x40100
ClassName = Window Class
title = MyWindow
dwStyle = 0x6CF0000
x = 0
y = 0
width = 621
height = 480
NULL
NULL
hInstance = 4194304
NULL
hWnd = 0
Error Code : 6

after this section of my program runs:

    hWnd = c_func(CreateWindowExA,{dwExStyle,
                                   ClassName,
                                   title,
                                   
or_all({WS_CLIPSIBLINGS,WS_CLIPCHILDREN,dwStyle}),
                                   0,
                                   0,
                                   peek4u(WindowRect + 4) - 
peek4u(WindowRect),
                                   peek4u(WindowRect + 12) - 
peek4u(WindowRect + 8),
                                   NULL,
                                   NULL,
                                   hInstance,
                                   NULL})

    printf(1,"dwExStyle = 0x%x\nClassName = %s\ntitle = %s\ndwStyle = 
0x%x\nx = 0\ny = 0\nwidth = %d\nheight = %d\nNULL\nNULL\nhInstance = 
%d\nNULL\n",
           
{dwExStyle,peek({ClassName,12}),peek({title,8}),or_all({WS_CLIPSIBLINGS,WS_CLIPCHILDREN,dwStyle}),
peek4u(WindowRect + 4) - peek4u(WindowRect),
           peek4u(WindowRect + 12) - peek4u(WindowRect + 8), hInstance})

    printf(1,"hWnd = %d\n",hWnd)

    if hWnd = NULL then
        printf(1,"Error code: %d\n",c_func(GetLastError,{}))
        if message_box("Window creation 
error","Error",or_bits(MB_OK,MB_ICONEXCLAMATION)) then end if
        return FALSE
    end if

Can anyone tell me why it fails with ERROR_INVALID_HANDLE (Error code 6)?

new topic     » topic index » view message » categorize

2. Re: window creation

Is the pointer to your callback valid?
hInstance...hmmm...have u tried simply including
instance(). How do you get values of hInstance?

----- Original Message -----
From: <1evan at sbcglobal.net>
To: "EUforum" <EUforum at topica.com>
Subject: window creation


>
> I get this:
>
> Class "Window Class" registered successfully   --generated after
> RegisterClassA function
> dwExStyle = 0x40100
> ClassName = Window Class
> title = MyWindow
> dwStyle = 0x6CF0000
> x = 0
> y = 0
> width = 621
> height = 480
> NULL
> NULL
> hInstance = 4194304
> NULL
> hWnd = 0
> Error Code : 6
>
> after this section of my program runs:
>
>     hWnd = c_func(CreateWindowExA,{dwExStyle,
>                                    ClassName,
>                                    title,
>
> or_all({WS_CLIPSIBLINGS,WS_CLIPCHILDREN,dwStyle}),
>                                    0,
>                                    0,
>                                    peek4u(WindowRect + 4) -
> peek4u(WindowRect),
>                                    peek4u(WindowRect + 12) -
> peek4u(WindowRect + 8),
>                                    NULL,
>                                    NULL,
>                                    hInstance,
>                                    NULL})
>
>     printf(1,"dwExStyle = 0x%x\nClassName = %s\ntitle = %s\ndwStyle =
> 0x%x\nx = 0\ny = 0\nwidth = %d\nheight = %d\nNULL\nNULL\nhInstance =
> %d\nNULL\n",
>
>
{dwExStyle,peek({ClassName,12}),peek({title,8}),or_all({WS_CLIPSIBLINGS,WS_C
LIPCHILDREN,dwStyle}),
> peek4u(WindowRect + 4) - peek4u(WindowRect),
>            peek4u(WindowRect + 12) - peek4u(WindowRect + 8), hInstance})
>
>     printf(1,"hWnd = %d\n",hWnd)
>
>     if hWnd = NULL then
>         printf(1,"Error code: %d\n",c_func(GetLastError,{}))
>         if message_box("Window creation
> error","Error",or_bits(MB_OK,MB_ICONEXCLAMATION)) then end if
>         return FALSE
>     end if
>
> Can anyone tell me why it fails with ERROR_INVALID_HANDLE (Error code 6)?
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: window creation

{{{ 1evan, Do you have this correct in your WinMain( ) function? wndclass = allocate(48) szAppName = allocate_string("wndclass")

Jordah, hInstance c_func(xGetModuleHandle, {0})

Euman

new topic     » goto parent     » topic index » view message » categorize

4. Re: window creation

id = routine_id("WndProc")
    if id = -1 then
    puts(1, "routine_id failed!\n")
    abort(1)
    end if
    WndProcAddress = call_back(id)
    wc = allocate(48)                          --was allocate(40), 
changed to 48, still no go
    WindowRect = allocate(16)
    ClassName = allocate_string("Window Class")
    poke4(WindowRect,0)
    poke4(WindowRect + 4,width)
    poke4(WindowRect + 8, 0)
    poke4(WindowRect + 12, height)
    hInstance = c_func(GetModuleHandleA,{NULL})
    poke4(wc,or_all({CS_HREDRAW, CS_VREDRAW, CS_OWNDC}))
    poke4(wc+4,WndProcAddress)
    poke4(wc+8,0)
    poke4(wc+12,0)
    poke4(wc+16,hInstance)
    poke4(wc+20,c_func(LoadIconA,{NULL,IDI_WINLOGO}))
    poke4(wc+24,c_func(LoadCursorA,{NULL, IDC_ARROW}))
    poke4(wc+28,NULL)
    poke4(wc+32,NULL)
    poke4(wc+36,ClassName)

    if not c_func(RegisterClassA,{wc}) then
        if message_box("Failed to register class","Error", 
or_bits(MB_OK,MB_ICONINFORMATION)) then end if
        return FALSE
    else
        printf(1,"Class %s registered 
successfully\n\n",{peek({ClassName,6})})
    end if

euman at bellsouth.net wrote:

>
>1evan,
>
>Do you have this correct in your WinMain( ) function?
>
>  wndclass  = allocate(48)
>
>  szAppName = allocate_string("wndclass")
>
>
>Jordah,
>
>hInstance = c_func(xGetModuleHandle, {0})
>
>
>Euman
>
>
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

-- 
     |\      _,,,---,,_
    /,`.-'`'    -.  ;-;;,_
   |,4-  ) )-,_..;\ (  `'-'
  '---''(_/--'  `-'\_)`-'\_)

new topic     » goto parent     » topic index » view message » categorize

5. Re: window creation

Actually I think it should be   *wc = allocate(40)*   because I am using 
WndClass structure and not WndClassEx.  No hIconSm or cbSize members to 
worry about.

1evan at sbcglobal.net wrote:

>    if id = -1 then
>    puts(1, "routine_id failed!\n")
>    abort(1)
>    end if
>    WndProcAddress = call_back(id)
>    wc = allocate(48)                          --was allocate(40), 
> changed to 48, still no go
>    WindowRect = allocate(16)
>    ClassName = allocate_string("Window Class")
>    poke4(WindowRect,0)
>    poke4(WindowRect + 4,width)
>    poke4(WindowRect + 8, 0)
>    poke4(WindowRect + 12, height)
>    hInstance = c_func(GetModuleHandleA,{NULL})
>    poke4(wc,or_all({CS_HREDRAW, CS_VREDRAW, CS_OWNDC}))
>    poke4(wc+4,WndProcAddress)
>    poke4(wc+8,0)
>    poke4(wc+12,0)
>    poke4(wc+16,hInstance)
>    poke4(wc+20,c_func(LoadIconA,{NULL,IDI_WINLOGO}))
>    poke4(wc+24,c_func(LoadCursorA,{NULL, IDC_ARROW}))
>    poke4(wc+28,NULL)
>    poke4(wc+32,NULL)
>    poke4(wc+36,ClassName)
>
>    if not c_func(RegisterClassA,{wc}) then
>        if message_box("Failed to register class","Error", 
> or_bits(MB_OK,MB_ICONINFORMATION)) then end if
>        return FALSE
>    else
>        printf(1,"Class %s registered 
> successfully\n\n",{peek({ClassName,6})})
>    end if
>
> euman at bellsouth.net wrote:
>
>>
>> 1evan,
>>
>> Do you have this correct in your WinMain( ) function?
>>
>>  wndclass  = allocate(48)
>>
>>  szAppName = allocate_string("wndclass")
>>
>>
>> Jordah,
>>
>> hInstance = c_func(xGetModuleHandle, {0})
>>
>>
>> Euman
>>
>>
>> TOPICA - Start your own email discussion group. FREE!
>>
>>

-- 
     |\      _,,,---,,_
    /,`.-'`'    -.  ;-;;,_
   |,4-  ) )-,_..;\ (  `'-'
  '---''(_/--'  `-'\_)`-'\_)

new topic     » goto parent     » topic index » view message » categorize

6. Re: window creation

> Actually I think it should be   *wc = allocate(40)*   because I am using
> WndClass structure and not WndClassEx.  No hIconSm or cbSize members to
> worry about.

cbSize is a mandatory element to fill in when dealing with either
structure(btw it exists for both structures). RegisterClass() or
RegisterClassEx() fails if its not filled in. That is the reason your
program fails.

==================
Jordah Ferguson
LogicSoft Dev.
http://pcplayground.com/gate.html?name=Sites&op=visit&lid=18

new topic     » goto parent     » topic index » view message » categorize

7. Re: window creation

I'll try that Monday as my program is on my work computer and I'm at 
home now.  I forgot to get a copy of it to work on at home. :(
Where should I put the cbSize member in WndClass? The SDK defines the 
structure as:

typedef struct {
    UINT style;
    WNDPROC lpfnWndProc;
    int cbClsExtra;
    int cbWndExtra;
    HINSTANCE hInstance;
    HICON hIcon;
    HCURSOR hCursor;
    HBRUSH hbrBackground;
    LPCTSTR lpszMenuName;
    LPCTSTR lpszClassName;
} WNDCLASS, *PWNDCLASS;

No mention of cbSize, where does it go?  Should it be the first element 
as in WndClassEx?

fred at jordah.freeserve.co.uk wrote:

>cbSize is a mandatory element to fill in when dealing with either
>structure(btw it exists for both structures). RegisterClass() or
>RegisterClassEx() fails if its not filled in. That is the reason your
>program fails.
>
>==================
>Jordah Ferguson
>LogicSoft Dev.
>http://pcplayground.com/gate.html?name=Sites&op=visit&lid=18
>
>
>
>TOPICA - Start your own email discussion group. FREE!
>  
>

new topic     » goto parent     » topic index » view message » categorize

8. Re: window creation

Sorry, i must've misinterpreted you. i thought u were using the wndclassex
and registerclassex structure.
I think it will be best if you attach your program for us to find the bugs
etc
typedef struct {
    UINT cbSize;
    UINT style;
    WNDPROC lpfnWndProc;
    int cbClsExtra;
    int cbWndExtra;
    HINSTANCE hInstance;
    HICON hIcon;
    HCURSOR hCursor;
    HBRUSH hbrBackground;
    LPCTSTR lpszMenuName;
    LPCTSTR lpszClassName;
    HICON hIconSm;
} WNDCLASSEX, *PWNDCLASSEX;
==================
Jordah Ferguson
LogicSoft Dev.
http://pcplayground.com/gate.html?name=Sites&op=visit&lid=18
----- Original Message -----
From: <1evan at sbcglobal.net>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, May 17, 2003 3:04 PM
Subject: Re: window creation


>
> I'll try that Monday as my program is on my work computer and I'm at
> home now.  I forgot to get a copy of it to work on at home. :(
> Where should I put the cbSize member in WndClass? The SDK defines the
> structure as:
>
> typedef struct {
>     UINT style;
>     WNDPROC lpfnWndProc;
>     int cbClsExtra;
>     int cbWndExtra;
>     HINSTANCE hInstance;
>     HICON hIcon;
>     HCURSOR hCursor;
>     HBRUSH hbrBackground;
>     LPCTSTR lpszMenuName;
>     LPCTSTR lpszClassName;
> } WNDCLASS, *PWNDCLASS;
>
> No mention of cbSize, where does it go?  Should it be the first element
> as in WndClassEx?
>
> fred at jordah.freeserve.co.uk wrote:
>
> >cbSize is a mandatory element to fill in when dealing with either
> >structure(btw it exists for both structures). RegisterClass() or
> >RegisterClassEx() fails if its not filled in. That is the reason your
> >program fails.
> >
> >==================
> >Jordah Ferguson
> >LogicSoft Dev.
> >http://pcplayground.com/gate.html?name=Sites&op=visit&lid=18
> >
> >
> >TOPICA - Start your own email discussion group. FREE!
> >
> >
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

9. Re: window creation

Not a problem.
I'll send the program Monday when I get back to work.

fred at jordah.freeserve.co.uk wrote:

>
>Sorry, i must've misinterpreted you. i thought u were using the wndclassex
>and registerclassex structure.
>I think it will be best if you attach your program for us to find the bugs
>etc
>typedef struct {
>    UINT cbSize;
>    UINT style;
>    WNDPROC lpfnWndProc;
>    int cbClsExtra;
>    int cbWndExtra;
>    HINSTANCE hInstance;
>    HICON hIcon;
>    HCURSOR hCursor;
>    HBRUSH hbrBackground;
>    LPCTSTR lpszMenuName;
>    LPCTSTR lpszClassName;
>    HICON hIconSm;
>} WNDCLASSEX, *PWNDCLASSEX;
>==================
>Jordah Ferguson
>LogicSoft Dev.
>http://pcplayground.com/gate.html?name=Sites&op=visit&lid=18
>----- Original Message -----
>From: <1evan at sbcglobal.net>
>To: "EUforum" <EUforum at topica.com>
>Sent: Saturday, May 17, 2003 3:04 PM
>Subject: Re: window creation
>
>
>>I'll try that Monday as my program is on my work computer and I'm at
>>home now.  I forgot to get a copy of it to work on at home. :(
>>Where should I put the cbSize member in WndClass? The SDK defines the
>>structure as:
>>
>>typedef struct {
>>    UINT style;
>>    WNDPROC lpfnWndProc;
>>    int cbClsExtra;
>>    int cbWndExtra;
>>    HINSTANCE hInstance;
>>    HICON hIcon;
>>    HCURSOR hCursor;
>>    HBRUSH hbrBackground;
>>    LPCTSTR lpszMenuName;
>>    LPCTSTR lpszClassName;
>>} WNDCLASS, *PWNDCLASS;
>>
>>No mention of cbSize, where does it go?  Should it be the first element
>>as in WndClassEx?
>>
>>fred at jordah.freeserve.co.uk wrote:
>>
>>    
>>>cbSize is a mandatory element to fill in when dealing with either
>>>structure(btw it exists for both structures). RegisterClass() or
>>>RegisterClassEx() fails if its not filled in. That is the reason your
>>>program fails.
>>>
>>>==================
>>>Jordah Ferguson
>>>LogicSoft Dev.
>>>http://pcplayground.com/gate.html?name=Sites&op=visit&lid=18
>>>
>>>
>>>TOPICA - Start your own email discussion group. FREE!
>>>
>>>
>>TOPICA - Start your own email discussion group. FREE!
>>
>>
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu