How to know the window class - OS2

This is a discussion on How to know the window class - OS2 ; I'm trying to process the WM_DRAWITEM message and I need to discover what type of control is posting it. Someting like: int class = SOME API; if(class == WC_MENU) paint the menu item else if(class == WC_LISTBOX) paint the list ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: How to know the window class

  1. How to know the window class

    I'm trying to process the WM_DRAWITEM message and I need to discover
    what type of control is posting it. Someting like:

    int class = SOME API;
    if(class == WC_MENU)
    paint the menu item
    else if(class == WC_LISTBOX)
    paint the list box

    Is there something like that.

    Thanks

  2. Re: How to know the window class

    In <1debb9d0-2850-46a4-8dbb-21f3440210cf@c65g2000hsa.googlegroups.com>, on
    06/25/2008
    at 09:00 AM, lpino said:

    Hi,

    >int class = SOME API;
    >if(class == WC_MENU)
    > paint the menu item
    >else if(class == WC_LISTBOX)
    > paint the list box


    >Is there something like that.


    You want WinQueryClassName(). What are you using to search pmref.inf?

    Steven

    --
    --------------------------------------------------------------------------------------------
    Steven Levine MR2/ICE 3.00 beta 11pre14 #10183
    eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
    --------------------------------------------------------------------------------------------


  3. Re: How to know the window class

    On 25 jun, 13:42, Steven Levine wrote:
    > In <1debb9d0-2850-46a4-8dbb-21f344021...@c65g2000hsa.googlegroups.com>, on
    > 06/25/2008
    > * *at 09:00 AM, lpino said:
    >
    > Hi,
    >
    > >int class = SOME API;
    > >if(class == WC_MENU)
    > > *paint the menu item
    > >else if(class == WC_LISTBOX)
    > > *paint the list box
    > >Is there something like that.

    >
    > You want WinQueryClassName(). *What are you using to search pmref.inf?
    >
    > Steven
    >
    > --
    > --------------------------------------------------------------------------------------------
    > Steven Levine *MR2/ICE 3.00 beta 11pre14 #10183
    > eCS/Warp/DIY/14.103a_W4www.scoug.comirc.ca.webbnet.info #scoug (Wed 7pm PST)
    > --------------------------------------------------------------------------------------------


    I'm searching using the search on PMVIEW. I saw that API, actually, I
    just found it to be "ugly" and in my case long to implement. But if
    that's the only choice it'll do

    Thanks you very much

  4. Re: How to know the window class

    Steven Levine schrieb:
    > In <1debb9d0-2850-46a4-8dbb-21f3440210cf@c65g2000hsa.googlegroups.com>, on
    > 06/25/2008
    > at 09:00 AM, lpino said:
    >
    > Hi,
    >
    >> int class = SOME API;
    >> if(class == WC_MENU)
    >> paint the menu item
    >> else if(class == WC_LISTBOX)
    >> paint the list box

    >
    >> Is there something like that.

    >
    > You want WinQueryClassName(). What are you using to search pmref.inf?
    >
    > Steven
    >


    Yes, but that is only half of the story as for the predefined PM window
    classes (WC_MENU,WC_MLE, etc), these are saved as atoms. You need
    something like this (this checks for PM window class WC_MENU for example):


    CHAR buf[6]; // 6 bytes is always enough if the window class name
    is saved as an atom
    HATOMTBL hatomtbl = WinQuerySystemAtomTable();
    ULONG ulLen = WinQueryClassName( theWnd, sizeof( buf ), buf);
    if (WinFindAtom(hatomtbl,buf) == WinFindAtom(hatomtbl,WC_MENU))
    {
    ...
    }

    This has been working for me for predefined PM window classes.

    Lars



  5. Re: How to know the window class

    On 25 jun, 14:04, Lars Erdmann wrote:
    > Steven Levine schrieb:
    >
    >
    >
    > > In <1debb9d0-2850-46a4-8dbb-21f344021...@c65g2000hsa.googlegroups.com>,on
    > > 06/25/2008
    > > * *at 09:00 AM, lpino said:

    >
    > > Hi,

    >
    > >> int class = SOME API;
    > >> if(class == WC_MENU)
    > >> *paint the menu item
    > >> else if(class == WC_LISTBOX)
    > >> *paint the list box

    >
    > >> Is there something like that.

    >
    > > You want WinQueryClassName(). *What are you using to search pmref.inf?

    >
    > > Steven

    >
    > Yes, but that is only half of the story as for the predefined PM window
    > classes (WC_MENU,WC_MLE, etc), these are saved as atoms. You need
    > something like this (this checks for PM window class WC_MENU for example):
    >
    > * * *CHAR buf[6]; // 6 bytes is always enough if the window class name
    > is saved as an atom
    > * * *HATOMTBL hatomtbl = WinQuerySystemAtomTable();
    > * * *ULONG ulLen = WinQueryClassName( theWnd, sizeof( buf ), buf);
    > * * *if (WinFindAtom(hatomtbl,buf) == WinFindAtom(hatomtbl,WC_MENU))
    > * * *{
    > * * * * ...
    > * * *}
    >
    > This has been working for me for predefined PM window classes.
    >
    > Lars


    Yeah,, I found that code too thanks. Talk about "ugly". Anyway I also
    found a very interesting page, where you can read about patents and I
    found several about OS/2. The detail of the docs is pretty good and it
    shows some internal work of the OS. Some references are old, probably
    from old versions of OS/2, but some others are pretty good.

    Here is one in case anybody wants something nerdy to read:
    http://www.patentstorm.us/patents/62...scription.html

    Thanks Lars for the tip. Now I need to implement 4 new apis


  6. Re: How to know the window class

    >>
    >> CHAR buf[6]; // 6 bytes is always enough if the window class name
    >> is saved as an atom
    >> HATOMTBL hatomtbl = WinQuerySystemAtomTable();
    >> ULONG ulLen = WinQueryClassName( theWnd, sizeof( buf ), buf);
    >> if (WinFindAtom(hatomtbl,buf) == WinFindAtom(hatomtbl,WC_MENU))
    >> {
    >> ...
    >> }
    >>
    >> This has been working for me for predefined PM window classes.
    >>
    >> Lars

    >
    > Yeah,, I found that code too thanks. Talk about "ugly". Anyway I also
    > found a very interesting page, where you can read about patents and I
    > found several about OS/2. The detail of the docs is pretty good and it
    > shows some internal work of the OS. Some references are old, probably
    > from old versions of OS/2, but some others are pretty good.
    >
    > Here is one in case anybody wants something nerdy to read:
    > http://www.patentstorm.us/patents/62...scription.html


    Jesus, that one is so cheap. It's useless if the functions have
    different parameters.

    >
    > Thanks Lars for the tip. Now I need to implement 4 new apis


    What 4 APIs ? Are you porting something and need to port the OS/2 API
    calls ?

    Lars

  7. Re: How to know the window class

    On 25 jun, 18:41, Lars Erdmann wrote:
    > >> CHAR buf[6]; // 6 bytes is always enough if the window class name
    > >> is saved as an atom
    > >> HATOMTBL hatomtbl = WinQuerySystemAtomTable();
    > >> ULONG ulLen = WinQueryClassName( theWnd, sizeof( buf ), buf);
    > >> if (WinFindAtom(hatomtbl,buf) == WinFindAtom(hatomtbl,WC_MENU))
    > >> {
    > >> ...
    > >> }

    >
    > >> This has been working for me for predefined PM window classes.

    >
    > >> Lars

    >
    > > Yeah,, I found that code too thanks. Talk about "ugly". Anyway I also
    > > found a very interesting page, where you can read about patents and I
    > > found several about OS/2. The detail of the docs is pretty good and it
    > > shows some internal work of the OS. Some references are old, probably
    > > from old versions of OS/2, but some others are pretty good.

    >
    > > Here is one in case anybody wants something nerdy to read:
    > >http://www.patentstorm.us/patents/62...scription.html

    >
    > Jesus, that one is so cheap. It's useless if the functions have
    > different parameters.
    >
    >
    >
    > > Thanks Lars for the tip. Now I need to implement 4 new apis

    >
    > What 4 APIs ? Are you porting something and need to port the OS/2 API
    > calls ?
    >
    > Lars


    I'm working on the SWT port and I need to implement the JNI calls to
    native APIs. A lot of them were implemented before I even got into the
    project, but as I progress I sometimes find APIs that are not on the
    list. The same goes for structures, although those are a lot more
    work. I'm pretty new to PM but I'm finally getting the hold of it and
    I just "finished" implementing the Menu class. Now it only uses text
    so far but I need to move on and implement the icon-text thing, that's
    why I'm getting into the WM_DRAWITEM and WM_MEASUREITEM messages.

    You can check the progress looking at http://svn.netlabs.org/swt/timeline
    or at the blog http://os2advocacy.blogspot.com/

    Thanks

  8. Re: How to know the window class

    In <4862889a$0$7550$9b4e6d93@newsspool1.arcor-online.net>, on 06/25/2008
    at 08:04 PM, Lars Erdmann said:

    Hi,

    >Yes, but that is only half of the story as for the predefined PM window
    >classes (WC_MENU,WC_MLE, etc), these are saved as atoms. You need
    >something like this (this checks for PM window class WC_MENU for
    >example):



    > CHAR buf[6]; // 6 bytes is always enough if the window class name
    >is saved as an atom
    > HATOMTBL hatomtbl = WinQuerySystemAtomTable();
    > ULONG ulLen = WinQueryClassName( theWnd, sizeof( buf ), buf);
    > if (WinFindAtom(hatomtbl,buf) == WinFindAtom(hatomtbl,WC_MENU))
    > {
    > ...
    > }


    This will work fine, but it is more work than needed when all you want to
    do is work with the predefined window classes. These are guaranteed to be
    integer form atoms, so the WinFindAtom can be safely bypassed, as in

    if (WinQueryClassName(hwndActive, sizeof(ucClassname), ucClassname)) {
    /* don't bring up help if a menu is active */
    if (!strcmp(ucClassname, "#4"))
    return;
    }

    If this method is used a lot, I would recommand defining a macro that
    generates a string given the WC_... value.

    Steven

    --
    --------------------------------------------------------------------------------------------
    Steven Levine MR2/ICE 3.00 beta 11pre14 #10183
    eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
    --------------------------------------------------------------------------------------------


  9. Re: How to know the window class

    On 25 jun, 20:26, Steven Levine wrote:
    > In <4862889a$0$7550$9b4e6...@newsspool1.arcor-online.net>, on 06/25/2008
    > * *at 08:04 PM, Lars Erdmann said:
    >
    > Hi,
    >
    > >Yes, but that is only half of the story as for the predefined PM window
    > >classes (WC_MENU,WC_MLE, etc), these are saved as atoms. You need
    > >something like this (this checks for PM window class WC_MENU for
    > >example):
    > > * * CHAR buf[6]; // 6 bytes is always enough if the window class name
    > >is saved as an atom
    > > * * HATOMTBL hatomtbl = WinQuerySystemAtomTable();
    > > * * ULONG ulLen = WinQueryClassName( theWnd, sizeof( buf ), buf);
    > > * * if (WinFindAtom(hatomtbl,buf) == WinFindAtom(hatomtbl,WC_MENU))
    > > * * {
    > > * *...
    > > * * }

    >
    > This will work fine, but it is more work than needed when all you want to
    > do is work with the predefined window classes. *These are guaranteed tobe
    > integer form atoms, so the WinFindAtom can be safely bypassed, as in
    >
    > * * if (WinQueryClassName(hwndActive, sizeof(ucClassname), ucClassname)) {
    > * * * /* don't bring up help if a menu is active */
    > * * * if (!strcmp(ucClassname, "#4"))
    > * * * * return;
    > * * }
    >
    > If this method is used a lot, I would recommand defining a macro that
    > generates a string given the WC_... value.
    >
    > Steven
    >
    > --
    > --------------------------------------------------------------------------------------------
    > Steven Levine *MR2/ICE 3.00 beta 11pre14 #10183
    > eCS/Warp/DIY/14.103a_W4www.scoug.comirc.ca.webbnet.info #scoug (Wed 7pm PST)
    > --------------------------------------------------------------------------------------------


    Thanks a lot. Even though I implemented all the needed calls, I ended
    using this method. Still I won't be able to complete the drawing of
    the items since I'm far from having all the skills. So for now SWT
    support only text menus. Now I'll move onto the Eclipse start code, so
    I can show people something. So far I can get the spalsh window to
    come up.

    Thanks again for rthe help.

+ Reply to Thread