1. Setting Icon....

Hy,

Does somebody know how to set a bitmap/icon
of a win32lib window?
Not in the window, but OF the window
(Upper-Left-Corner at the blue line).
setIcon() doesn't work.
And I read in a program that if you use sendMessage(),
you have to use command 128, but that doesn't work also.

Can somebody help me?

Bye,
PQ
QC

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » topic index » view message » categorize

2. Re: Setting Icon....

Hi Patrick,

Yes, I did that once, but I had to hack win32lib.ew pretty badly to do it.
I tried to email David Cuny, but it bounced back, and I forgot about it.
Let me show him how I did it, and see what he wants to do with it.

BTW, you are correct that #80 (128) is the correct sendMessage code, but it
won't work in win32lib because of some issues with global constants.

Brian Jackson
bjackson at printinginc.com

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

3. Re: Setting Icon....

I am confused by what you mean by command 128.

There are two types of main windows in mswindow.
A single window and a MDI ( mutiple doctument interface )

A single main window has no child windows.

A MDI window would be like an editor that creates multiple child windows
for each document, etc.

The Single window when its created is assign a default icon.

I do not think you can change it on the fly. So you have to assign your

own icon as the deault icon when you create it.

But a MDI window I think can change the icon of any of its child

by sending a message to it because it creates these child windows.

So are trying to change a single window or a MDI window ?

If its a single window use your ICON as the default when creating it.

To change the MDI you have find out the correct message to send.

I hope this helps you.

Bernie

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

4. Re: Setting Icon....

At 12:24 PM 28-02-1999 , you wrote:
>The Single window when its created is assign a default icon.
>I do not think you can change it on the fly. So you have to assign your
>own icon as the deault icon when you create it.
>
>But a MDI window I think can change the icon of any of its child
>by sending a message to it because it creates these child windows.
>So are trying to change a single window or a MDI window ?
>If its a single window use your ICON as the default when creating it.
>To change the MDI you have find out the correct message to send.

In fact the icon used in a window is defined on it's window class. You can
send a WM_SETICON message, but the message is only recognized on Win9x, not
NT. If you want to change it at runtime you need to get (or create) a new
icon handle and modify the window class with the SetClassLong() WinAPI
function. In the following code I use the LoadImage() API function to load
from file an icon. The ChangeWindowIcon modifies the small icon associated
with the window (GCL_HICONSM). The small icon is displayed on the left-top
corner of the window and in the taskbar. The large icon (GCL_HICON) is used
when switching task using ALT+TAB. I tested the code and worked fine (on NT
4.0). I modified window.exw (on %EUDIR%\DEMO\WIN32) to call
ChangeWindowIcon when creating the Window (WM_CREATE), tell me if it works
OK on other circumstances. Perhaps it requieres a repaint before displaying
the new icon.


--[CHANGEICON.EW]--
include dll.e

-- Class field offsets for GetClassLong()
global constant
GCL_MENUNAME = -8,                      -- Pointer to the menu name string
GCL_HBRBACKGROUND = -10,        -- Handle to the default background brush
GCL_HCURSOR = -12,                      -- Handle to the window class cursor

GCL_HICON = -14,                                -- Handle to the window class
icon
GCL_HMODULE = -16,                      -- Handle of the module that registered
the class
GCL_CBWNDEXTRA = -18,           -- Size of extra memory associated with each
--window
                                                                        of this class, in bytes.
GCL_CBCLSEXTRA = -20,           -- Size of the extra memory associated with this
--class,
                                                                        in bytes.
GCL_WNDPROC = -24,                      -- Pointer to the window procedure for
this class.
--If a
                                                                        developer replaces the window procedure
--using
                                                                        this index, it must conform to the window
--procedure callback definition as outlined in the
--RegisterClass function. This subclass will affect
--all
                                                                        windows subsequently created with this class.
--An
                                                                        application should not subclass a window created
--by
                                                                        another process.
GCL_STYLE = -26,                                -- 32-bit style bits for this
class
GCW_ATOM = -32,                         -- Atom that uniquely identifies this
class. This
--is the
                                                                        same atom returned by the RegisterClass
--and
                                                                        RegisterClassEx functions
GCL_HICONSM = -34                       --Handle to the window class small icon

-- LoadImage() constants
global constant
        IMAGE_BITMAP = 0,
        IMAGE_ICON = 1,
        IMAGE_CURSOR = 2,
        IMAGE_ENHMETAFILE = 3,

  LR_DEFAULTCOLOR = #0000,
  LR_MONOCHROME = #0001,
  LR_COLOR = #0002,
  LR_COPYRETURNORG = #0004,
  LR_COPYDELETEORG = #0008,
  LR_LOADFROMFILE = #0010,
  LR_LOADTRANSPARENT = #0020,
  LR_DEFAULTSIZE = #0040,
  LR_VGACOLOR = #0080,
  LR_LOADMAP3DCOLORS = #1000,
  LR_CREATEDIBSECTION = #2000,
  LR_COPYFROMRESOURCE = #4000,
  LR_SHARED = #8000

atom user32, ApiSetClassLong, ApiLoadImage

procedure init()
        user32 = open_dll("user32.dll")
        ApiSetClassLong = define_c_func(user32, "SetClassLongA", {C_INT, C_INT,
C_LONG}, C_LONG)
        ApiLoadImage = define_c_func(user32, "LoadImageA", {C_INT, C_POINTER,
C_UINT, C_INT, C_INT, C_UINT}, C_LONG)
end procedure

global function LoadImage(integer hinst, sequence name, integer utype,
integer cxDesired, integer cyDesired, integer fuLoad)
        atom lpszname
        lpszname = allocate_string(name)
return c_func(ApiLoadImage, {hinst, lpszname, utype, cxDesired,
        cyDesired,
fuLoad})
        free(lpszname)
end function

global function SetClassLong(integer hwnd, integer nIndex, integer NewVal)
        return c_func(ApiSetClassLong, {hwnd, nIndex, NewVal})
end function

global function ChangeWindowIcon(integer hwnd, sequence icon_file)
        integer hicon
        hicon = LoadImage(0, icon_file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE)
        return SetClassLong(hwnd, GCL_HICONSM, hicon)
end

init()

--[TEST.EXW]--
include changeicon.ew

--TO DO: Create and populate window

-- hwnd = window handle
ChangeWindowIcon(hwnd, "path\\icon_file.ico")



Regards,
         Daniel  Berstein
         [daber at pair.com]

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

5. Re: Setting Icon....

>From:         Bernie Ryan <bwryan at PCOM.NET>
>Subject:      Re: Setting Icon....
>
>I am confused by what you mean by command 128.
>There are two types of main windows in mswindow.
>A single window and a MDI ( mutiple doctument interface )
>A single main window has no child windows.
>A MDI window would be like an editor that creates multiple child
windows
>for each document, etc.
>The Single window when its created is assign a default icon.
>I do not think you can change it on the fly. So you have to assign your
>own icon as the deault icon when you create it.
>But a MDI window I think can change the icon of any of its child
>by sending a message to it because it creates these child windows.
>So are trying to change a single window or a MDI window ?
>If its a single window use your ICON as the default when creating it.
>To change the MDI you have find out the correct message to send.

What has MDI to do with Icons ?
! Nothing !
I'm talking about changing the
upper-left picture before the title in the blue line in a window.

This supposed to be a WINDOW,
The # is a ICON,
- is MINIMIZE BUTTON,
<> is MAXIMIZE/RESTORE button,
X is CLOSE BUTTON.

 _____________________
[# TITLE        - <> X]
-----------------------
|                     |
|                     |
|                     |
|                     |
-----------------------


GET IT !?

Bye,
PQ
QC


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

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

6. Re: Setting Icon....

That ( titlebar or caption or system menu )icon what ever you want to call

it can appear in two places in an MDI WINDOW, on the APPLICATION WINDOW

or on the DOCUMENT WINDOW.

A SINGLE WINDOW has only ONE ICON because it is only a APPLICATION

WINDOW ( No child windows ).

All of these windows display an ICON on the little blue line at the top.


You did not explain which of the ICON's you wanted to change or in what

type of windows.

Bernie

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

7. Re: Setting Icon....

At 06:40 PM 28-02-1999 , you wrote:
>That ( titlebar or caption or system menu )icon what ever you want to call
>it can appear in two places in an MDI WINDOW, on the APPLICATION WINDOW
>or on the DOCUMENT WINDOW.
>A SINGLE WINDOW has only ONE ICON because it is only a APPLICATION
>WINDOW ( No child windows ).
>All of these windows display an ICON on the little blue line at the top.
>You did not explain which of the ICON's you wanted to change or in what
>type of windows.
>
>Bernie

The code I sent earlier can handle any window. It just need a handle to the
window.

Tell me if it works on 95/98 (it should).


Regards,
         Daniel  Berstein
         [daber at pair.com]

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

Search



Quick Links

User menu

Not signed in.

Misc Menu