Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

change the default form's icon on a DLL

Posted on 2003-11-17
10
Medium Priority
?
382 Views
Last Modified: 2010-05-01
Hi lads, this is driving me nuts.
I'm trying to change the default windows icon that comes with a DLL's form. The thing is as soon as I press Alt-Tab to change to a different application, I can see the windows flag as an icon for my form. I found out that when I use an Active EXE project (with an icon selected), and take it to call a DLL's form (with an icon as well), my DLL's form shows its icon. My problem is that I'm calling this DLL from a word document, so my DLL seems to not recognize its 'parent', showing the ugly  windows default icon instead. Any idea on how to change and use one of my choice at design/run-time?

Thanks guys
Toni
0
Comment
Question by:AntoniL
  • 5
  • 4
10 Comments
 
LVL 7

Accepted Solution

by:
wsteegmans earned 750 total points
ID: 9767740
Maybe you can use some API-stuff to do your thing ...

I found that you can get the current icon with this MESSAGE: WM_GETICON

Maybe, this page helps:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q259/6/73.asp&NoWebContent=1
0
 

Author Comment

by:AntoniL
ID: 9767902
Hi mate,
the thing about that example (tried a few days ago!!, cheers anyway) is that the icon gets disfigured with ICON_BIG and with ICON_SMALL the form remains as at the beginning ... any idea on how to fix that or any other way?

thanks wsteegmans

Toni
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9768416
This is how it is done:
HOWTO: Associate a Custom Icon with a Formless Visual Basic Application
http://support.microsoft.com/default.aspx?scid=kb;en-us;291569

Also, please maintain your old open questions:
1 09/07/2003 250 Refresh browser's frame content from VB  Open VB Controls
2 07/03/2003 250 call a DLL or EXE passing parameters  Open JavaScript
3 08/07/2003 500 Writing a PDF file with VB  Open VB Controls

Thanks,
Anthony
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:AntoniL
ID: 9770062
Hi acperkins,
this example is for Formless executables, so doesn't apply to my case. I tried to do the same as in the link you mentioned and doesn't work. Thanks anyway

Anybody else guys?

Toni
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9771484
>>this example is for Formless executables, so doesn't apply to my case. <<
A dll is a "Formless" executable, in the sense that it does not have (or should not have) a form.

>>I tried to do the same as in the link you mentioned and doesn't work.
I do not know why it did not "work" for you, but on the other hand you do not appear to have any interest in maintaining your open questions, so I will move on.

Good luck,
Anthony
0
 

Author Comment

by:AntoniL
ID: 9773133
Thanks for your input acperkins,
sorry but the example of 'formless executables' did work when I tried for an EXE but did not for a DLL, and what I'm looking for is for a DLL. I did a few tries but didn't find any way to get it working for a DLL.
I indeed have interest in my open questions, if they remain open is because I still have some hope for an answer. I'm not going to close them just in case. EE sends an email after a few months asking to close them up, and it's then when I'm 'forced' to do it. Of course it's up to you to move on. Thanks for your replies, honestly.

See you around

Toni
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9773581
>>if they remain open is because I still have some hope for an answer.<<
The chances that someone will address a question that is at best two months old and at worse four months old are exactly 0. To put it mildly you are delluding yourself. Questions are considered technically abandoned after 21 days.

>>EE sends an email after a few months asking to close them up <<
That is not the way it works here.  Volunteers like myself are assigned abandoned questions and we recommend the outcome: Award points, Delete without a Refund or Delete and refund.  So basically you are saying that your questions will fall in the following category:

Abandon your question and leave the mess for someone else to clean up
http://www.experts-exchange.com/help/closing.jsp#12

>> it's then when I'm 'forced' to do it.<<
You are never forced to do anything, it is your responsibility as a member of this Community to keep up to date with your questions.

Thank you for your help,
Anthony
0
 

Author Comment

by:AntoniL
ID: 9777208
Hi acperkins,
I didn't know after just 3 weeks the questions become technically 'dead'. Thanks for letting me know. I just opened a thread on the CleanUp Area asking for deletion for my 3 abandoned questions.
Any chance to get an answer in this, still, open question? ;-), really need to get it.

Thanks for your help lads

Toni
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9784347
Thanks for closing your old open questions.  Hopefully someone will offer some help.

Anthony
0
 

Author Comment

by:AntoniL
ID: 9786441
OK lads, I think I found the solution. The key thing here is have a couple of Picture controls, with an icon as their image. The first, Picture1, has an icon with just one format, 32x32, and the second, Picture2, has the small format, 16x16, or if you like, with all the formats, it doesn't matter. With the firsts lines of code, we set up the large icon for the Alt-Tab, and in the end, we change the icon to a small format, for the Task-Bar. Remember, the important thing is the one-format icon, 32x32.
Here is the code:

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

 Const GWL_HWNDPARENT = (-8)

 Const WM_GETICON = &H7F
 Const WM_SETICON = &H80
 Const ICON_BIG = 1

Private Sub Form_Load()
    Dim hIcon As Long
    Dim nRet As Long
    Dim nMainhWnd As Long
   
    nRet = GetWindowLong(Me.hWnd, GWL_HWNDPARENT)
    nMainhWnd = nRet
    nRet = GetWindowLong(nRet, GWL_HWNDPARENT)
    Me.Icon = Picture1.Picture
    hIcon = SendMessage(Me.hWnd, WM_GETICON, ICON_BIG, ByVal 0)
    SendMessage nMainhWnd, WM_SETICON, ICON_BIG, ByVal hIcon
    Me.Icon = Picture2.Picture
End Sub

The points go to wsteegmans for putting me on the right track.
Thanks to you all guys, see you around

Toni
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question