Solved

change the default form's icon on a DLL

Posted on 2003-11-17
10
367 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 73
Using an encrypted  value to decrypt and display contents in vb6 9 51
TT Auto Dashboard 13 92
Automatic Email Reminder 4 36
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

785 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