Solved

change the default form's icon on a DLL

Posted on 2003-11-17
10
365 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 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:AntoniL
Comment Utility
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
Comment Utility
>>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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:AntoniL
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
Thanks for closing your old open questions.  Hopefully someone will offer some help.

Anthony
0
 

Author Comment

by:AntoniL
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now