Loading Icon From resource-failed - VC++ matlab Interface

Hello all,

    first of all, this is VC++  ~ Matlab interface doubt.

Iam trying to change the icon of the Matlab figure Window using
windows dll. For this I am trying to load the icon from the
resource.But it is failing. Am getting hicon as null.

I tested the code with independed WIN32 app , it is fine.

Source code is attached.

#include <windows.h>
#include <string.h>
#include <shellapi.h>
#include "mex.h"
#include "resource.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray
HWND hwnd;
HICON hicon;
char *wind;
int len;

len = mxGetN(prhs[0])+1;
wind = mxCalloc(len,sizeof(char));
mxGetString(prhs[0], wind, len);

/* get window */
hwnd = FindWindow(NULL, wind);

if (hwnd==NULL)
mexErrMsgTxt("window handle missing");

hicon = LoadIcon(hwnd, (LPCTSTR)IDI_ICON1);

if(hicon ==NULL)
mexErrMsgTxt("icon handle missing.");

/* icon */
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon);


Thanks very much

imran.ar (4)
6/28/2005 8:41:20 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 13

>Iam trying to change the icon of the Matlab figure Window using
>windows dll. For this I am trying to load the icon from the
>resource.But it is failing. Am getting hicon as null.
>I tested the code with independed WIN32 app , it is fine.

I'm surprised, given this:

>hicon = LoadIcon(hwnd, (LPCTSTR)IDI_ICON1);

.... when the first parameter should be the instance handle of the
module containing the resource - not the window handle.

davidl7375 (2060)
6/28/2005 9:37:13 AM

Similar Artilces:

loading network card information ...error provider load failure
This is a multi-part message in MIME format. ------=_NextPart_000_000F_01CA7D92.03F9F310 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi there, I get "loading network card information ...error provider load failure" = when I go and use systeminfo.exe . How can I fix this? Thanks, Gordon ------=_NextPart_000_000F_01CA7D92.03F9F310 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN&qu...

Conference Room as a Resource
I have setup an exchange account for a conference room we have here and set it up as a resource so now it with automatically accept meetings when it is added as a resource. My problem is that the default permissions are set to author and I do not want employees to be able to open the conference room's calendar and view all the meetings listed there. Sometimes the meeting content is sensative with regard to terminations or other HR issues and we do not want people viewing the meeting details. However when I set the permissions back to none or a custom permissions with no r...

OWA (Not Loading)
Does anyone know of any issues with Satellite Service and the right side of OWA not loading. The left side loads but the user cannot see anything on the right. OWA works from any other connection. Thanks, KG ...

SOS,how to load a invalid or damaged .gif file to create Image Object.
hi everyone. my question is this:how to load a .gif image file that is invalid or damaged image format? Notice,I want to load the invalid damaged image file to operate it. my code is below,but all of they are not correct. -------- 1.Image.FromFile(fileName);load from a file directly,it throws a OutOfMemoryException.In msdn,it's mean the file is a invalid image format. 2.Image.FromStream(stream);load from stream,it throws a ArgumentException. -------- ps:IE and Google Picasa can load and display the damaged .gif file correct. Or there is any other methods to operate the i...

Outlook Client Install -Failed
Calling custom action Microsoft.Crm.Setup.Client!Microsoft.Crm.Setup.Client.ClientSetup.DatabaseAction Database Installer custom action failed. ...

Outlook will not open after clicking Icon
Hello I seem to have mysteriously lost my Outlook connection. When I click on the icon, the hourglass appears for a few seconds, then goes away. Any ideas? Alex Does Outlook start in safe mode? (start | run | type: outlook.exe /safe | ok button) If Outlook 2000 (part of Office 2000), are any of the other applications just quitting right after launch? "Alex" <almo67sf@pacbell.net> wrote in message news:04e401c34fde$df626f10$a401280a@phx.gbl... > Hello > > I seem to have mysteriously lost my Outlook connection. > When I click on the icon, the hourglass appea...

Simple drawing application fails
Hi, I have a simple application where I draw som lines and circles in two funtions called by the OnPaint(). However it fails. One function draws an 'X' and the other 'O' in the ClientDc. The problem is that I only get som '/' instead of an 'X' when drawing an 'X'? Does this has something to do with which device context I use? In the turorial I have the onPaint handler uses the CPaintDc dc and passes the dc as a pointer to the functions meanwhile in my code I use the CClientDC locally in the function? This is my pseudo code: OnPaint() { dra...

my page number icons disappeared.
How do I get my page number icons to reappear? I don't know how they disappeared. GabPub wrote: > How do I get my page number icons to reappear? I don't know how they > disappeared. ===================== Up to the 2003 version go to... View / Status Bar For the 2007 version have a look at the following article:: Where is the Page Sorter (status bar) in Publisher 2007 Or...Why can't I change pages in Publisher 2007 http://ed.mvps.org/Static.aspx?=Publisher/FAQs (scroll down to : Where is the Page Sorter in Publisher 2007) -- John Inzer MS-MVP Digital Media Expe...

Icon displaying badly in Taskbar
Hi all, I have a problem with an icon in my program being displayed differently in the main window titlebar and in taskbar. The icon is a red letter alpha on transparent background. When shown in the taskbar, a black border is drawn around the letter, resulting in an unclean look. I uploaded a magnified screenshot to illustrate the problem http://www.geocities.com/vitplanocka/Clipboard02.gif I have experimented with various icon sizes and colour resolutions and found that the icon being displayed in both the title bar and the taskbar is an icon 32x32x256. It just seems to be displayed ...

Error loading CRM 3.0 Client with Outlook
I receive error message "An error occurred loading Microsoft CRM Functionality" when starting Outlook with CRM 3.0 client installed. I have uninstalled CRM, Office, and cleaned the register using Register Mechanic. I am now getting the same error with an event error "A problem occurred initializing Microsoft CRM COM interopt". Anyone have any ideas? Thanks. I have the exact same issue has anyone found a solution to this? I am running all avialable updates on both Office 2003 and XP Pro, I DO NOT have the Business Contact Manager for Outlook installed. "rtop...

Sent Mail Icons
Can anyone tell me what a small envelope w/ an 'i' icon in the 'Sent Mail' folder means...? ------------------------------------------------ ~~ Message posted from http://www.OutlookForum.com/ ~~ View and post usenet messages directly from http://www.OutlookForum.com/ ...

Outlook 97 fails to open
Hi All, I have a client who installed Office 97 Pro on her XP computer. She set up Outlook but used the Exchange mode instead of POP when setting up her account. She tried to correct her problem but has since called me in. She has also since installed SP2. When Outlook opens it looks for a .pst file that does not exist. No matter what option you choose Outlook then fails and closes without giving you a chance to do anything else. The error is ID: 1000 Source: Application Error. I have tried uninstalling and reinstalling but had no luck. -- John Harris (Harry) Computer Troublesh...

We just upgraded from 1.2 to 3.0. When user tried to run reports, they get Login Failed for user 'NT AUTHORITY/ANONYMOUS LOGON' error. However, if I log directly into the CRM server with the same user account, it runs fine. I went through KB909588 re: Configure Kerberos authentication for Microsoft CRM 3.0 and Microsoft SQL Server Reporting Services and I believe we have everything set correctly. i checked the SRS sites and they are set for pass-through authentication (not anonymous). Any other ideas on what would cause this. Try solving it with this article.... <http://downl...

loading web application project suddonly takes 5 mintues and says "Contacting server to open Web project.." wile it takes 5 minutes to load. how to fix? i tried reregistering asp.net and iisreset. no
loading web application project suddonly takes 5 mintues and says "Contacting server to open Web project.." wile it takes 5 minutes to load. how to fix? i tried reregistering asp.net and iisreset. no progres. ...

Device Registration failed
I have gone through the deployment of the CRM Mobile on PPC6700 Sprint have a VPN setup and Getting device registration failed. Probably a Certificate issue but can someone advise on where to start looking? Much appreciation When you created the installation item for your PPC6700, under the "Settings 1" there is a https value for "CRM Mobile message bus URL:" Copy that https value and paste in onto a web browser - any security alert prompt? If there is alert prompt, then it is mostly a certificate issue. Need to setup so that the alert prompt doesn't show up....

No Add member varible as control available in .NET2003 MFC Lib32 resources !
I professionally work with a rather large project and I have splitting the 'Solution' into a number of Win32 Lib projects using VS 6.0. While migrating to .NET2003, the new Add Member Variable-Wizard can't generate dialog member controls (stuff is grayed out). It works with MFC EXE and MFC DLL applications (I suspect because they have CWinApp derived class), but not with resources in Win32 MFC LIB-projects. Is this a known problem in .NET IDE, are there any workaround ? Right now I'm thinking about staying with VS 6.0 ...

Publisher Fails To Open
I have been using Publisher, which came bundled with Microsoft Office 2000 Premium, for a year and a half. Now, for reasons I cannot determine, it simply fails to open, whether I use the shortcut on the desktop or the start menu. I get no error message of any sort -- the desktop just continues unaltered. I have tried uninstalling Microsoft Office and reinstalling it and still cannot open Publisher, though the other programs bundled in Microsoft Office open just fine. Any advice? -- Bill B Delete the shortcut and create a new one. To do this, follow these steps: 1.Delete the broken...

What do I load ?
Hello. I'm trying to develop a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 comuter. If i comsume this web service: https://xatanet.net/xatanetwebservice/tripexportservice.asmx and do this operation: RetrieveArchivedTrips using: Dim strDate As Date = "2006-04-01" Dim endDate As Date = "2006-04-28" proxy.RetrieveArchivedTrips(strDate, endDate) What do I load when i use the following statements in my program: Dim doc as XmlDocument = new XmlDocument() doc.Load() Any...

controlling icon drawing in CListCtrl
hi there i have implemented a CListCtrl which displays graphic images as normal icons i have created for each item in the list several images relating to unselected, selected, drophilited, and hover states, and have written the code to update the image item index when the appropriate events occur all is going well, except i have one last 'issue' i would like resolve - when an item is selected in LVS_ICON mode in a CListCtrl, the icon's text is painted white on blue, and the icon has some kind of 'mask' applied to it to appear selected - i would like to prevent the icon ...

Logon failed
I am using Live Mail as my default program. When I try to sent a attachment by clicking mail attachment in word 2007 to go through live mail I get this notice. Logon failed. You must log on to Microsoft Exchange to access your address book. What does this mean? Using Office works 2007. W7 professional. Any help would be appreciated. Grumpy Are you using Word's "Send Email" feature? Or are you in WLMail and selecting "Attach", then locating a file via Windows Explorer? "Grumpy" <Grumpy@discussions.microsoft.com> wrote ...

Debug image fails to load.
Hi, I created an OS design with KITL, Kernel debugger enabled in Debug mode. But when i try to load the image to the CEPC it fails to boot. I am attaching the log here. ------ SERIAL PORT LOG starts ----------- Microsoft Windows CE Ethernet Bootloader Common Library Version 1.0 Built Dec 9 2002 18:35:13 Copyright (c) 2000-2001 Microsoft Corporation Microsoft Windows CE Ethernet Bootloader 3.3 for CE/PC (Feb 6 2003) Boot Args @ 0x1F136 and ucLoaderFlags is 1 PCI Device Configurations (3 PCI bus(es) present)... ======================================================== Bus, Devi...

User interface 03-30-10
I want to create a form where the client will fill in information on a website and it will tie in to the Access database. an ex. would be eHarmony or Carfax. Access is not a good choice for a web application. The sites you list do not run on Access! For this you should look into a tool such as MySQL, SQLServer, Postgres, ... -- Hope this helps, Daniel Pineault http://www.cardaconsultants.com/ For Access Tips and Examples: http://www.devhut.net Please rate this post using the vote buttons if it was helpful. "Renaissance2000" wrote: > I want to create...

Resource not found
Hy, when i try to send a message i receive an error reporting "Resource not found", i've this erro sending messages via owa. My exchange server have installed Exchange 2003 Sp2. What can i do to solve this problem? Any Suggestions? Thanks Kentucky Sounds like you need to configure URLscan to support the OWA Look at these 2 articles http://support.microsoft.com/kb/309508/ http://support.microsoft.com/kb/325965 -- Best regards. Kenneth Johansen MCSA,MCSE on Windows 2000 (Soon mcse, mcsa on Windows 2003 , mcdba and MCAD) "Kentucky" wrote: > Hy, when i try to sen...

Click on a link and a picture loads in cell depending on which link you have clicked
Hello If I have five links in cells A1:A5 with peoples names. How can get... e.g. If I click on Bill in A2 then a picture of Bill loads in cell D1 an then click Mark and a picture of Mark loads in D1. Thanks in advanc -- Message posted from http://www.ExcelForum.com I'm not sure what you mean by link in A1 through A5, but I'd try it this way: Put all 5 pictures on the worksheet and position them where you want them. Name them to match the values in A1:A5. Select the picture for Bill and then type Bill in the name box (to the left of the formulabar) and hit enter. After all 5...

DB Maintenance Plan With Exec SQL Server Agent Job Task
Running SQL 2005 Standard with current sp's. I have a DB maintenance job. That job also has an "Execute SQL Server Agent Job Task" step in it - at the top. During my testing, if I set that Agent job step to fail and run it manually outside of the Mainteance Plan and it failes. When the same "test fail" agent task runs in the maintenance plan, it continues to run. The constraint for that Agent job task in the DB maintneance plan is SUCCESSFULL. It should not be continuing the run but it does. Any ideas? That is by design - since the Execute SQL Server Agent...