Setting a small icon in CStatic...

Does anyone know how to set a small icon in the CStatic class?

Normally I am fine doing this with my own icons, as I use ::LoadImage and
pass in the icon size of 16x16. However I want to do this with a system
icon, such as IDI_INFORMATION. For some reason LoadImage does not take
notice that I want the icon size to be 16x16, and instead uses the default
of 32x32.

Heres a snippet of my code...

   HICON hInfo = (HICON) LoadImage(0,

MAKEINTRESOURCE(IDI_INFORMATION),
                                                                IMAGE_ICON,
                                                                16,
                                                                16,
                                                                LR_SHARED);

    // icon size should be 16x16, however, when set it uses the 32x32
size...
   ((CStatic*) GetDlgItem(IDC_MYICON))->SetIcon(hInfo);

Any help would be appreciated.

Thanks.
-- 

Dave

Note: Spam-resistant e-mail address


0
6/17/2004 5:39:48 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1544 Views

Similar Articles

[PageSpeed] 37

There are some interesting comments in the docs relating to LR_SHARED and
"non-standard" sizes etc... might be worth a look. Might be worth trying
LR_DEFAULTCOLOR.

Bill

PS Please don't do ((CStatic *)GetDlgItem())-> it makes me sad (and will
make you cry some day for sure). Attach a member variable of type CStatic to
the control.


"Dave" <davidp_au@nospam.yahoo.com> wrote in message
news:%23UAgtxCVEHA.2816@TK2MSFTNGP11.phx.gbl...
> Does anyone know how to set a small icon in the CStatic class?
>
> Normally I am fine doing this with my own icons, as I use ::LoadImage and
> pass in the icon size of 16x16. However I want to do this with a system
> icon, such as IDI_INFORMATION. For some reason LoadImage does not take
> notice that I want the icon size to be 16x16, and instead uses the default
> of 32x32.
>
> Heres a snippet of my code...
>
>    HICON hInfo = (HICON) LoadImage(0,
>
> MAKEINTRESOURCE(IDI_INFORMATION),
>
IMAGE_ICON,
>                                                                 16,
>                                                                 16,
>
LR_SHARED);
>
>     // icon size should be 16x16, however, when set it uses the 32x32
> size...
>    ((CStatic*) GetDlgItem(IDC_MYICON))->SetIcon(hInfo);
>
> Any help would be appreciated.
>
> Thanks.
> -- 
>
> Dave
>
> Note: Spam-resistant e-mail address
>
>


0
GuitarBill
6/17/2004 6:10:51 AM
Two comments:

I've attached member variable to CStatic in the past - and don't bother 
anymore.  Never has it been a problem, and the GetDlgItem(IDC...) is 
fast, efficient, and allows easy handling of a group of static items 
(such as captions for edit boxes) in loops.

CStatic items are also an easy way to make pseudo-buttons, since it has 
the ability to capture mouse-clicks.  Good-looking borderless (if 
desired), easily colored (or iconed or bitmapped) buttons.  Almost no 
functionality beyond the click events, but rarely do I need more.

Balboos

GuitarBill wrote:
> There are some interesting comments in the docs relating to LR_SHARED and
> "non-standard" sizes etc... might be worth a look. Might be worth trying
> LR_DEFAULTCOLOR.
> 
> Bill
> 
> PS Please don't do ((CStatic *)GetDlgItem())-> it makes me sad (and will
> make you cry some day for sure). Attach a member variable of type CStatic to
> the control.
> 
> 
> "Dave" <davidp_au@nospam.yahoo.com> wrote in message
> news:%23UAgtxCVEHA.2816@TK2MSFTNGP11.phx.gbl...
> 
>>Does anyone know how to set a small icon in the CStatic class?
>>
>>Normally I am fine doing this with my own icons, as I use ::LoadImage and
>>pass in the icon size of 16x16. However I want to do this with a system
>>icon, such as IDI_INFORMATION. For some reason LoadImage does not take
>>notice that I want the icon size to be 16x16, and instead uses the default
>>of 32x32.
>>
>>Heres a snippet of my code...
>>
>>   HICON hInfo = (HICON) LoadImage(0,
>>
>>MAKEINTRESOURCE(IDI_INFORMATION),
>>
> 
> IMAGE_ICON,
> 
>>                                                                16,
>>                                                                16,
>>
> 
> LR_SHARED);
> 
>>    // icon size should be 16x16, however, when set it uses the 32x32
>>size...
>>   ((CStatic*) GetDlgItem(IDC_MYICON))->SetIcon(hInfo);
>>
>>Any help would be appreciated.
>>
>>Thanks.
>>-- 
>>
>>Dave
>>
>>Note: Spam-resistant e-mail address
>>
>>
> 
> 
> 

0
balboos (139)
6/17/2004 9:44:18 AM
Reply:

Similar Artilces:

How set default vCard viewer?
This could be a WindowsXP-pro question or Outlook2002 question, unsure. A small window popped up entitled "Address Book" and the message was "Address Book is currently not your default vCard viewer. Would you like to make it your default vCard viewer? [Yes] [No] How do you (manually) get to the place in WindowsXP-pro or somewhere else like in Outlook where you specify the default vCard viewer, I can't find anywhere. Also, is vCard viewer related to a .vcf file? Thanks Do you have a Palm Pilot? If you have installed some Palm Software, at times it will make itself the...

in VBA
Using Office 2003 I would like to reset any custom filter settings from all columns. The following resets Column 1 only: Selection.AutoFilter Field:=1 What is the VBA code to reset Columns 1-17? TIA Dennis Dennis, Selection.AutoFilter You could have found that out by yourself if you had just used Macro Record (as I did). -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Dennis" <dmburgess@removespamameritech.net> wrote in message news:961i10teu4q5r2t6rh38bmen6lski9r6f6@...

Copies of Table with Arrow Icons
I have a table called Quotes2004. Somewhere along the line two additional tables appeared called Quotes20041 and Quotes20042, each with an arrow icon next to them. I understand that the arrow indicates a link. But, I don't recall making these table copies. Can some process make the copies automatically? As far as I can tell, they are exact copies of Quotes2004 and they are updated when I update Quotes2004. How can I determine how these were created, what the links are and if they are really necessary? To discover what a table is linked to, open it in design view. Then open the Prope...

Using A Macro/VBA code to re-set formulas
Hi can any one help me with a Macro/VBA code to re-set formulas in pre-defined set of cells i.e. in my case C14:C40 At present I have a copy of the Formulas in another part of th worksheet and when I want to reset the worksheet (as the user can ove right the formulas as the formula is based on either the sum of anothe two cells or the users input) I use a Macro to copy and paste (special the formulas. What I require is a Macro/VBA Code which already has the formula store in the actual Macro/VBA code i.e. so they are not stored as copy in m worksheet Ay help would be greatly appreciated T...

Single Space Setting
When I am trying to type a list of items in single space, Word wants to double space. How can I change this setting so that everything is single spaced? Thanks!!! GAB This is not actually single spacing, it's a "space after" setting that Microsoft enabled for the default Normal style. To get rid of it, click on Format>Style, make sure "Normal" is selected in the list, then click on Modify. Choose Paragraph from the dropdown button which reads Format, then set the Spacing After to 0 pt. Click on OK, then check the box that reads "Add to Template". Go back...

Attn Publisher Users: Setting your Text Defaults!
Ok, wanna know how to save your text defaults for all future publications for Publisher 2002/2003. We have just discovered that you do NOT need the add-in that we developed. This feature has been there all along, since Publisher 2002 as a matter of fact. The Normal.pub feature (like the normal.dot feature in Microsoft Word) is actually present in these last two versions. Yes, it has been there all along! Thanks to Alex at Microsoft, as he was kind enough to point out after all these years that it truly does exist. I have created a tutorial, which is very simple: http://www.publishermvp...

NTP-settings problem with IT Environment Health Scanner
Hi! I´d like to know what configuration the tool "IT Environment Health Scanner" looks for when checking NTP-settings in Active Directory. We have configured the time source for PDC-emulator in Forest with GPO and verified the settings with w32tm /monitor and it reports the new NTP-server as intended. But when the IT Environment Health Scanner checks for the NTP-server setting on the PDC-emulator, it reports the setting to be time.microsoft.com: ---- 8< ------ Report -------------------- Time sources are defined correctly for domain controllers Warning: The ...

VBA calling sp with ANSI_NULLS set ON
Hi, On Query Analyzer, I created a sp as follow: > > if exists (select * from dbo.sysobjects where id = object_id(N'dbo.PCS_SEG1') and OBJECTPROPERTY(id, N'IsProcedure')= 1) DROP PROCEDURE dbo.PCS_SEG1 GO CREATE PROCEDURE dbo.PCS_SEG1 as set ANSI_NULLS on set ANSI_WARNINGS on ** sql statement *** > > I need the to set ANSI_NULLS and ANSI_WARNINGS on as it involves another server using linked server. When executing the sp from query analyzer, it works fine too: > exec PCS_SEG1 > But, when I called from VBA, I received error: Heterogeneous queries require t...

I want to set a customized default to print envelopes..
I would like to know if anyone has set customized setting to print envelopes. So it will not print in a bin but on the default bin of the printer and be manually fed... Prior to 2003 the supervisor was able to just select envelope and it would want to be manually feed and print to the default bin... and not cause everything else to print to the default. ...

Can I set up cascading combo boxes in a TABLE?
I am setting up a database for a research project. I would like to enter the data within the table as it is easier to see everything together. I have a combo box for General Injury Region, which is upper extremity, lower extremity, spine. I would like to the second combo box populate based on the first with shoulder, hand, wrist, etc. Thanks in advance! Debi wrote: > I am setting up a database for a research project. I would like to enter > the data within the table as it is easier to see everything together. > > I have a combo box for General Injury Region, wh...

reply/forward icon
The field for the reply and forward icons is not present and thus I cannot see those icons when I forward or reply to a message. Bummer - care to share the version of Outlook, the message editor, when it last worked, and what you did to make it stop working (installation of new software, uninstallations, etc.) --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Ed Gask...

Hardware Requirements for Small Scale CRM Demo
Hi guys, I want to install SQL Server 2005 and CRM 3.0 on the following hardware: Dell 1400SC, 933Mhz PIII, 640MB RAM, 18GB U160 SCSI Q: Is this hardware going to be sufficient for a small scale demo or is it going to crawl? Robert you might get by if you could somehow get the RAM up to 1Gb or more. I think she might crawl, but worth a try as-is. If you get it all working and it's still slow, spend some $ on RAM. Dave "MS" <robert@upstateis.com> wrote in message news:%23Zg8aM8NGHA.208@tk2msftngp13.phx.gbl... > Hi guys, > > I want to install SQL Ser...

Rotating hourglass icon in status bar
I have recently started using Outlook 2003. I noticed that there is an icon in the shape of an hourglass in the status bar. The icon continuously rotates. When right clicked, it presents a menu with items Details... and Cancel, both of which are greyed out. Can someone tell me the purpose of the icon and how I might be able to hide it? Thanks, Jim ...

Question on organizing large amounts of small Excel Files
I have a question regarding how I can best organize large amounts of excel worksheets so that they are more managable. I am using Excel 2002, and my problem is that the tool logs for the machine that I work with are getting out of hand. The machine stores process information in Comma Delimited form that we download into folders on our network drive. Usually we generate about 1500 logs per year. Currently, my Engineer has me open each individual file and format it. I created a small micro for this to make it easier, but it is still time consuming. Is there a way to apply a micro to large a...

Setting database location to SQL Server
Hello, I'm looking to move the POS system database from the local MSDE database to a SQL server. I've restored a recent backup (.bck) to a SQL server machine on our network and I'm looking for information on how to reconnect the POS to the new SQL server. Before we go live I will restore a new backup but I'm just testing the solution for now. The overall plan is to separate the database from the cash register and allow SQL server to perform backups and other normal database task. Is there a separate configuration tool for changing data connection information? ...

Set up a Certificate of Deposit / Forex account
What is the best way to set up a CD in Money? -as an investment (in an investment account) with the interest "reinvested" each month? -as an investment account using only the cash portion and adding "interest" each month? -as a "savings account" under "banking"? Also, how should a forex account be set up? Thank you for any help you can provide I have set up CD's as either investments within an investment account or as individual savings accounts. It all has depended upon how the FI treats them. When I did not have anything but manual entry...

Object reference not set to an instance of an object.
Hello, I have some code which simply reads a RSS with the XmlTextReader and XmlDocument. Unfortunaly I get the error: Object reference not set to an instance of an object. Here is my simple code: private function CheckRSS(byval strRSS as string) Dim reader as new XmlTextReader(strRSS) Dim xmlDoc as XmlDocument Try xmlDoc.Load(reader) Catch ex As Exception Response.Write("ERR in Rss File:" & strRSS & "<br>") Response.Write("Err: RSS File:" & ex.Message & "...

Set Cell Padding on word tables with merged cells
Dear Experts: Below macro sets certain padding values for the selected table. Regrettably it fails to work on tables with merged cells. Have you got any idea how to re-write the code so that tables featuring merged cells also get worked on? Help is much appreciated. Thank you very much in advance. Regards, Andreas Sub SetPadding Dim myCell As Cell Dim myRow As row Dim myTable As Table Set myTable = Selection.Tables(1) For Each myRow In myTable.rows For Each myCell In myRow.Cells myCell.TopPadding = CentimetersToPoints(0) myCell.BottomPadding = C...

Animation of Icons in Visio 2000
Can we animate any Icon (from a Stencil) onto a Work page? ...

no send icon in my outlook
Has anyone ever had or heard of a copy of outlook not having a send icon within it? My outlook 03 does not have a send icon anywhere. Can someone help me? canrolski <anonymous@discussions.microsoft.com> wrote: > Has anyone ever had or heard of a copy of outlook not > having a send icon within it? My outlook 03 does not > have a send icon anywhere. Can someone help me? The Send button doesn't appear until you create a valid Email account. -- Brian Tillman When you create a new message (or reply or forward), there is no SEND icon. Is that what you're saying? I...

HELP! Settings are not saving
Every time I open my excel, my calcualtion keeps going back to manual. It even happens in the middle of working on a spreadsheet. Also, if I hit save or save as, when I close the worksheet is ALWAYS asks if I want to save. It has been happening for a week or two. Any ideas???? Any chance the files you're working on are Read Only? [that may not be it, but just a thought] "Veronica" wrote: > Every time I open my excel, my calcualtion keeps going back to manual. It > even happens in the middle of working on a spreadsheet. Also, if I hit save > or save as, when I c...

150 Badges Icons Set PSD.exe (7/7)
=ybegin part=7 line=128 size=1593874 name=150 Badges Icons Set PSD.exe =ypart begin=1497601 end=1593874 �C[=@a=}�/��`�5Ҵ�b��,�'���r�?������/��3NV���q���w�3x��`A���7,$D2=J_SOfu�4p�"��Z&N�褜#-n���̷�@��r�/��5�QҬу��� I͠)?{7@�%��[�ym�z��^�~�:���ڑYdkŝ��� Dx���@3��8�p+�"y��$E�ޓeْ2�b<=}STTY]�=@T9W�6����P�%��C��^o�x+1��c�5[O|N�I�KD xb��1Œ�bz$Ӭk�#⺶H���C:��h��,E�?�\?���~��0볈�j�+���T���ay�$���Y%��-��5���<=}�i+�?O�7�#�m�%V�d��9Bc>Qv_;=}�V��w� ��&�S�F6����3���/;^�n�x��=J���>�$��H���WK�\�-�v�+:dyw�=J��A���n���J-����J�haak�]w���...

setting the same choice and order of the fields in all the folders
This is a multi-part message in MIME format. ------=_NextPart_000_0008_01C422DC.8D05E5E0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable How do I set the same choice and order of the fields in all the folders? For the moment the View settings apply to a particular folder and I have = to set them manually in every folder. ------=_NextPart_000_0008_01C422DC.8D05E5E0 Content-Type: text/html; charset="koi8-r" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <...

How do I set home to A1 instead of K1?
If I press the home key on an existing spreadsheet, it goes to K1 instead of to A1. Is there a way I can fix this? If not, do I have another possible problem on that spreadsheet? I suspect that you have the window 'frozen' at column K. In pre-2007 Excel menu: Window --> Unfreeze Panes Excel 2007: [View] tab, Window Group, in the Freeze Panes pull-down, choose Unfreeze Panes "Julie D" wrote: > If I press the home key on an existing spreadsheet, it goes to K1 instead of > to A1. Is there a way I can fix this? If not, do I have another possibl...

How do I set up a GANTT chart for a research proposal
Don't Know what to put in a GANTT chart for a research proposal, how to actually lay it out, my subject is nursing research.. do include costs of researcher etc EXCEL 2007 I have just put up a file for you at:- http://www.pierrefondes.com/ - item number 78 towards th top of my home page. This is based on MS documentation. If my comments have helped please hit Yes. Thanks. "HiLo" wrote: > Don't Know what to put in a GANTT chart for a research proposal, how to > actually lay it out, my subject is nursing research.. do include costs ...