Icon in der Titelleiste bei B+ Fenstern
Übersicht

![]() |
XenonBetreff: Icon in der Titelleiste bei B+ Fenstern |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi Leuz,
Es war ein Stückchen Arbeit das rauszufinden und thx an Suco-X der mir mit LoadImage geholfen hat. Und kein thx an die MSDN, weil ich solang gebraucht hab um WM_SETICON zu finden =) Nagut ich will euch nicht länger aufhalten. Ihr braucht als erstes diese Userlibfunktionen: Code: [AUSKLAPPEN] .lib "User32.dll"
SendMessage%(hwnd,msg,wParam,lParam):"SendMessageA" LoadImageC%(hinst, Name$, type, cx%, cy%,fuLoad):"LoadImageA" Diese Konstanten: Code: [AUSKLAPPEN] Const WM_SETICON = $80
Const LR_LOADFROMFILE = $10 Const ICON_SMALL = 0 Const ICON_BIG = 1 Const IMAGE_ICON = 1 und diesen Code: Code: [AUSKLAPPEN] icon = LoadImageC(0, iconname$, IMAGE_ICON, 0, 0, LR_LOADFROMFILE)
SendMessage(QueryObject(hWnd, 1), WM_SETICON, ICON_SMALL, icon) SendMessage(QueryObject(hWnd, 1), WM_SETICON, ICON_BIG, icon) Wobei iconname$ der Dateiname eures Icons ist und hWnd euer Fensterhandle, dass ihr von CreateWindow() zurückbekommen habt. Noch zu Info: Das ICON_SMALL ist das 16x16 Icon in der Icon Datei. Dieses Icon wird beim Fenster in die Titelleiste gesetzt. Das ICON_BIG hingegen ist das 32x32 Icon in der Icon Datei. Dieses Icon sieht man, wenn man zB Alt+Tab drückt. Mfg Xenon |
||
![]() |
Xenon |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ist das Icon im selben Ordner?
Ist das Icon auch eine richtige Icon Datei? Die Datei muss ein 16x16 Icon enthalten für die Titelleiste und ein 32x32 Icon für Alt+Tab =) Ich hab mein Icon mit MSVC++ erstellt. Kleine Anleitung: MSVC++ starten, im Menü Datei-->Neu, Dateien Tab auswählen, auf Symbol-Datei doppelklicken, bei Gerät steht Standard (32x32) dort neben auf den kleinen Button drücken, auf Klein (16x16) doppelklicken, jetzt die beiden Icons zeichnen, im Menü Datei-->Speichern, Pfad aussuchen, Dateinamen eingeben, Speichern drücken, Fertig! Wenn das Icon stimmt, kannst du noch die Variablen icon, hWnd und Queryobject(hWnd, 1) auf 0 überprüfen! Und vor allem müssen die Konstanten korrekt sein, sonst passiert nämlich auch nix. Mfg Xenon |
||
lettorTrepuS |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
-aus Sicherheitsgründen gelöscht- Diese Information ist mit Ihrer Sicherheitsfreigabe leider nicht erhältlich, Bürger. | ||
![]() |
Xenon |
![]() Antworten mit Zitat ![]() |
---|---|---|
DAS funktioniert nicht! | ||
lettorTrepuS |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
-aus Sicherheitsgründen gelöscht- Diese Information ist mit Ihrer Sicherheitsfreigabe leider nicht erhältlich, Bürger. | ||
Kekskiller |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Bei mir stimmt alles.
Das Icon hat ein 16*16- und ein 32*32-Bildchen. Beide wurden auch erfolgreich in die Exe vorher eingefügt. Kann es sein, dass vorher kein Icon vorhanden sein darf? Ansonsten wird es wohl an Kompatibilitäten mit meinem Compi liegen... |
||
![]() |
Xenon |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ähm das Icon muss im selben Ordner sein!
wenn es zB Icon.ico heißt, dann musst du im Code bei LoadImageC statt iconname$ eben "Icon.ico" einsetzen. Das als Ressource hinzufügen bei der Exe bewirkt lediglich das die Exe im Explorer dieses Icon erhält. |
||
Kekskiller |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hab ich doch gesagt, alles ist perfekt.
Dann lass ich das, würde sowieso keinen guten Eindruck machen, wenn ich ein kleines über vier großen Symbolen + Cursor hätte. |
||
![]() |
Xenon |
![]() Antworten mit Zitat ![]() |
---|---|---|
Schick mir mal den Code und das Icon ich werd versuchen es zum laufen zu bringen. | ||
Kekskiller |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Code: [AUSKLAPPEN] Const WM_SETICON=$80
Const LR_LOADFROMFILE=$10 Const ICON_SMALL=0 Const ICON_BIG=1 Const IMAGE_ICON=1 Global window=CreateWindow("Pixelator - <anonym>",(ClientWidth(Desktop())-305)/2,(ClientHeight(Desktop())-300)/2,305,300,0,01+02+04+08) SetMinWindowSize window,305,300:AppTitle "Pixelator" icon=LoadImageC(0,"Pixelatoricon.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE) SendMessage(QueryObject(window,1),WM_SETICON,ICON_SMALL,icon) SendMessage(QueryObject(window,1),WM_SETICON, ICON_BIG,icon) Repeat event=WaitEvent() Select event Case $803:End End Select Forever Nix mit Icon. Vielleicht war ich auch zu bescheuert... |
||
![]() |
Xenon |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich hab rausgefunden warum das so ist!
So komisch es klingen mag, es liegt an der Statuszeile im Fenster. Lass mal beim Fensterstyle das +08 weg und es geht! Begründung hab ich keine, find ich echt komisch. |
||
Kekskiller |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hey, schön, jetzt klappts, danke.
Aber ohne Statusleiste glaube ich, bleibt Pixelator vorerst ohne Icon. Denn ohne wäre es nen bißchen leer ^_^ . Aber sonst gibt das sicher Verwendung. Toll. |
||
Kekskiller |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Mir fällt da gerade die Konstante: LR_LOADFROMFILE
Da gibt es doch sicher noch ne Konstante, um das Exe-interne Icon zu verwenden. Na, wie schauts aus ![]() |
||
![]() |
Xenon |
![]() Antworten mit Zitat ![]() |
---|---|---|
MSDN hat Folgendes geschrieben: LR_DEFAULTCOLOR The default flag; it does nothing. All it means is "not LR_MONOCHROME".
LR_CREATEDIBSECTION When the uType parameter specifies IMAGE_BITMAP, causes the function to return a DIB section bitmap rather than a compatible bitmap. This flag is useful for loading a bitmap without mapping it to the colors of the display device. LR_DEFAULTSIZE Uses the width or height specified by the system metric values for cursors or icons, if the cxDesired or cyDesired values are set to zero. If this flag is not specified and cxDesired and cyDesired are set to zero, the function uses the actual resource size. If the resource contains multiple images, the function uses the size of the first image. LR_LOADFROMFILE Loads the image from the file specified by the lpszName parameter. If this flag is not specified, lpszName is the name of the resource. LR_LOADMAP3DCOLORS Searches the color table for the image and replaces the following shades of gray with the corresponding 3D color: Color Replaced with Dk Gray, RGB(128,128,128) COLOR_3DSHADOW Gray, RGB(192,192,192) COLOR_3DFACE Lt Gray, RGB(223,223,223) COLOR_3DLIGHT LR_LOADTRANSPARENT Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the default window color (COLOR_WINDOW). All pixels in the image that use that entry become the default window color. This value applies only to images that have corresponding color tables. If fuLoad includes both the LR_LOADTRANSPARENT and LR_LOADMAP3DCOLORS values, LRLOADTRANSPARENT takes precedence. However, the color table entry is replaced with COLOR_3DFACE rather than COLOR_WINDOW. LR_MONOCHROME Loads the image in black and white. LR_SHARED Shares the image handle if the image is loaded multiple times. If LR_SHARED is not set, a second call to LoadImage for the same resource will load the image again and return a different handle. Do not use LR_SHARED for images that have non-standard sizes, that may change after loading, or that are loaded from a file. Windows 95 and Windows 98: The function finds the first image with the requested resource name in the cache, regardless of the size requested. LR_VGACOLOR Uses true VGA colors. |
||
![]() |
Uncle Ho |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi ho
habe euer beispiel mal ausprobiert und um eine funktion erweitert. so kann man das exe-interne icon anzeigen: erst die userlibs um kernel32.dll erweitern Code: [AUSKLAPPEN] .lib "user32.dll" SendMessage%(hwnd,msg,wParam,lParam):"SendMessageA" LoadImageC%(hinst, Name$, type, cx%, cy%,fuLoad):"LoadImageA" .lib "kernel32.dll" GetModuleHandle_Null%(lpModuleName%):"GetModuleHandleA" dann der bb-code: Code: [AUSKLAPPEN] Const WM_SETICON = $80 Const LR_LOADFROMFILE = 0 Const ICON_SMALL = 0 Const ICON_BIG = 1 Const IMAGE_ICON = 1 inst% = GetModuleHandle_Null(0) iconname$ = "TESTICON" ; Name welcher nacher in ResourceHacker Eingetragen werden muss hWnd=CreateWindow("TestApp",(ClientWidth(Desktop())/2)-(640/2),(ClientHeight(Desktop())/2)-(480/2),640,480,0,7) icon = LoadImageC(inst%, iconname$, IMAGE_ICON, 0, 0, LR_LOADFROMFILE) SendMessage(QueryObject(hWnd, 1), WM_SETICON, ICON_SMALL, icon) SendMessage(QueryObject(hWnd, 1), WM_SETICON, ICON_BIG, icon) Repeat Until WaitEvent () = $803 End RescourceHacker dann eine .exe erstellen und in RescourceHacker eine neue resource hinzufügen. das Icon einfügen und den namen auf iconname$ (also hier "TESTICON") einstellen. abspeichern. fertig. Bei mir klappt es so ohne externe icon-datei. |
||
___________________________________
GUNG HO |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group