1. Win32Lib: Window Icon
- Posted by Brian Broker <bkb at CNW.COM> Feb 25, 2000
- 528 views
Just wondering if there is a better way to do this... I want to bind a program with a custom icon and have that icon be displayed in the corner of my window. I am using the following code. -- start snippet -- sequence cl cl = command_line() setIcon( MyWindow, cl[2] ) -- end snippet -- This assures that the icon will show up in my window regardless of what the executable is named. So is there a better way to accomplish this? If not, may I suggest to David that this might make a good example for 'setIcon' in 'Win32Lib.htm'. --Brian
2. Re: Win32Lib: Window Icon
- Posted by Caballero Rojo <pampeano at ROCKETMAIL.COM> Feb 25, 2000
- 477 views
- Last edited Feb 26, 2000
Hello Brian, Just use the .ico file when you not compile your program. And when you're going to do it, change the ico file to the executable file =) -- Best regards, Caballero Rojo mailto:pampeano at rocketmail.com Friday, February 25, 2000, 6:24:56 AM, you wrote: BB> Just wondering if there is a better way to do this... I want to bind a BB> program with a custom icon and have that icon be displayed in the corner of BB> my window. I am using the following code. BB> -- start snippet -- BB> sequence cl BB> cl = command_line() BB> setIcon( MyWindow, cl[2] ) BB> -- end snippet -- BB> This assures that the icon will show up in my window regardless of what the BB> executable is named. BB> So is there a better way to accomplish this? If not, may I suggest to BB> David that this might make a good example for 'setIcon' in 'Win32Lib.htm'. BB> --Brian __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com
3. Re: Win32Lib: Window Icon
- Posted by Brian Broker <bkb at CNW.COM> Feb 25, 2000
- 488 views
On Fri, 25 Feb 2000 19:41:36 -0300, Caballero Rojo wrote: >Hello Brian, > Just use the .ico file when you not compile your program. > And when you're going to do it, change the ico file to the > executable file =) Thanks, I realize that. The point I was trying to make was that when you bind a program with an icon, and you want that icon to show up in your application's window, you need a way of saying "use the icon that is contained in this executable, regardless of what is called". When I first starting adding icons to bound programs, I was doing something like: setIcon( MyWindow, "MyProgram.exe" ) Well, this works fine until you rename "MyProgram.exe" to "MyOldProgram.exe". (Now your program won't find "MyProgram.exe" and won't show it's icon in the window.) By using 'command_line' to get the name of your program, you can be assured that the icon will always show up in your bound app's window. Unless somebody knew of a better way to do this, I was merely pointing out a not-so-obvious idea for other users of Win32Lib who want to bind their programs with custom icons... (at least it wasn't initially obvious to me and I just thought that it might be a nice example for the Win32Lib documentation). -- Brian
4. Re: Win32Lib: Window Icon
- Posted by Bernie Ryan <LockCityData at CS.COM> Feb 25, 2000
- 476 views
On Fri, 25 Feb 2000 16:54:52 -0500, Brian Broker <bkb at CNW.COM> wrote: >Unless somebody knew of a better way to do this, I was merely pointing out >a not-so-obvious idea for other users of Win32Lib who want to bind their >programs with custom icons... (at least it wasn't initially obvious to me >and I just thought that it might be a nice example for the Win32Lib >documentation). > Brian: Look at the WNDCLASSEX structure in windows. You will find a member called cbClsExtra which specifies the number of EXTRA bytes to allocate following the window's instance. Now if you can convince David ( or edit your copy of win32lib ) to allow you to change this size to fit your Icon. You can store your Icon there and it will always be available no matter what you call your program. You will have to figure out how to get it's offset, I think you can use GetWindowLong with nIndex and use that to grab and copy out 32 bits at a time. Bernie
5. Re: Win32Lib: Window Icon
- Posted by Robert Craig <rds at ATTCANADA.NET> Feb 25, 2000
- 475 views
- Last edited Feb 26, 2000
Brian Broker writes: > Just wondering if there is a better way to do this... > I want to bind a program with a custom icon and have > that icon be displayed in the corner of my window. > I am using the following code. > > -- start snippet -- > sequence cl > cl = command_line() > setIcon( MyWindow, cl[2] ) > -- end snippet -- > > This assures that the icon will show up in my window > regardless of what the executable is named. You should look at euphoria\demo\win32\window.exw in the Euphoria 2.2 release. It contains the code that you need to display an icon in the top left corner of a window. The 3 key lines are: icon_handle = c_func(LoadIcon, {instance(), allocate_string("exw")}) poke4(wndclass + hIcon, icon_handle) poke4(wndclass + hIconSm, icon_handle) The standard icon contained in exw.exe for 2.2 is called "exw" regardless of what you call your bound .exe file. When you run bindw, you can specify an icon of your own, but the name will still be "exw". Your icon must contain a single image, and be 2238 bytes or less in size, otherwise it might not be displayed. (see bind.doc) Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
6. Re: Win32Lib: Window Icon
- Posted by Mathew Hounsell <mfh03 at UOW.EDU.AU> Feb 26, 2000
- 483 views
- Last edited Feb 27, 2000
Date sent: Fri, 25 Feb 2000 18:11:38 -0500 From: Bernie Ryan <LockCityData at CS.COM> Subject: Re: Win32Lib: Window Icon > Look at the WNDCLASSEX structure in windows. You will find a > member called cbClsExtra which specifies the number of EXTRA bytes > to allocate following the window's instance. Now if you can convince > David ( or edit your copy of win32lib ) to allow you to change > this size to fit your Icon. You can store your Icon there and it > will always be available no matter what you call your program. > You will have to figure out how to get it's offset, I think you > can use GetWindowLong with nIndex and use that to grab and copy > out 32 bits at a time. One small problem, the Windows will not allow extra size of more than 40 bytes per window class. Also it is a runtime thing. ------------------------- Sincerely, Mathew Hounsell mat.hounsell at excite.com