Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » VC++ / MFC » Icon größe/dimension ermitteln

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
18.09.2005, 10:48 Uhr
LowFly



hy,
wie kann ich die größe eines Icons ermitteln das ich aus einer exe o. dll usw. auslese?
gibt es eine möglichkeit direckt aus der datei abzufragen wie groß das dort enthaltene icon ist. ich hab mich mal in der msdn umgesehn und bin dabei über LookupIconIdFromDirectoryEx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/icons/iconreference/iconfunctions/lookupiconidfromdirectoryex.asp
gestolpert. leider kann ich damit nicht so richtig was anfangen und bin mir auch nicht sicher ob es für meine zwecke geeignet ist.
wenn ich mir das beispiel Sharing Icon Resources anschaue bzw. dies in meine Anwendung kopiere bekomme ich fehlermeldungen.


Fehler Code:

hMem = LoadResource(hExe, hResource); <--error 1

lpResource = LockResource(hMem); <--error 2


hMem = LoadResource(hExe, hResource); <--error 3

lpResource = LockResource(hMem); <--error 4




Zitat von Fehlermeldungen:

1 error C2440: '=' : 'void *' kann nicht in 'struct HRSRC__ *' konvertiert werden Konvertierung von 'void*' in Zeiger auf nicht-'void' erfordert eine explizite Typumwandlung

2 error C2440: '=' : 'void *' kann nicht in 'unsigned char *' konvertiert werden Konvertierung von 'void*' in Zeiger auf nicht-'void' erfordert eine explizite Typumwandlung

3 error C2440: '=' : 'void *' kann nicht in 'struct HRSRC__ *' konvertiert werden Konvertierung von 'void*' in Zeiger auf nicht-'void' erfordert eine explizite Typumwandlung

4 error C2440: '=' : 'void *' kann nicht in 'unsigned char *' konvertiert werden Konvertierung von 'void*' in Zeiger auf nicht-'void' erfordert eine explizite Typumwandlung





Orginal Code:

HICON hIcon1;       // icon handle
HINSTANCE hExe;     // handle to loaded .EXE file
HRSRC hResource;    // handle for FindResource  
HRSRC hMem;         // handle for LoadResource
BYTE *lpResource;   // pointer to resource data  
int nID;            // ID of resource that best fits current screen

HDC hdc;        // handle to display context

// Load the file from which to copy the icon.
// Note: LoadLibrary should have a fully explicit path.
//
hExe = LoadLibrary("C:\\WINNT\\system32\\SHELL32.DLL");
if (hExe == NULL)
{
    //Error loading module -- fail as securely as possible
    return;
}


// Find the icon directory whose identifier is 440.

hResource = FindResource(hExe,
    MAKEINTRESOURCE(440),
    RT_GROUP_ICON);

// Load and lock the icon directory.

hMem = LoadResource(hExe, hResource);

lpResource = LockResource(hMem);

// Get the identifier of the icon that is most appropriate
// for the video display.

nID = LookupIconIdFromDirectoryEx((PBYTE) lpResource, TRUE,
    CXICON, CYICON, LR_DEFAULTCOLOR);

// Find the bits for the nID icon.

hResource = FindResource(hExe,
    MAKEINTRESOURCE(nID),
    MAKEINTRESOURCE(RT_ICON));

// Load and lock the icon.

hMem = LoadResource(hExe, hResource);

lpResource = LockResource(hMem);

// Create a handle to the icon.

hIcon1 = CreateIconFromResourceEx((PBYTE) lpResource,
    SizeofResource(hExe, hResource), TRUE, 0x00030000,
    CXICON, CYICON, LR_DEFAULTCOLOR);




Kann mir dabei jemand behilflich sein.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
18.09.2005, 13:05 Uhr
FloSoft
Medialer Over-Flow
(Administrator)


du musst casten, dann sind die fehlermeldungen weg.

ansonsten:

SizeofResource
--
class God : public ChuckNorris { };
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ VC++ / MFC ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: