hounder Posted May 6, 2010 Share Posted May 6, 2010 (edited) heres my current code, $pIcon = @WindowsDir & '\system32\cmd.exe' $iconStruct = DllStructCreate("int Handle") _WinAPI_ExtractIconEx($pIcon, 0, 0, DllStructGetPtr($iconStruct), 1) $hIcon = DllStructGetData($iconStruct, "Handle", 1) _WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) cant quite seem to figure out how to draw one of my own icons, instead of grabbing another icon from an .exe. IE. i want to draw "favicon.ico". help anyone? Edited May 6, 2010 by hounder Link to comment Share on other sites More sharing options...
Yashied Posted May 6, 2010 Share Posted May 6, 2010 What is $hDC? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
hounder Posted May 6, 2010 Author Share Posted May 6, 2010 What is $hDC?$hDC = _WinAPI_GetDC($GuiMain) Link to comment Share on other sites More sharing options...
Yashied Posted May 6, 2010 Share Posted May 6, 2010 What is $GuiMain? Give us a working code, please. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
trancexx Posted May 6, 2010 Share Posted May 6, 2010 hounder you need to do different things. Like here: ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include <WindowsConstants.au3> #include <WinAPI.au3> Global $hGui = GUICreate("") Global $hDC = _WinAPI_GetDC($hGui) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX $pIcon = @WindowsDir & '\system32\cmd.exe' $iconStruct = DllStructCreate("int Handle") _WinAPI_ExtractIconEx($pIcon, 0, 0, DllStructGetPtr($iconStruct), 1) $hIcon = DllStructGetData($iconStruct, "Handle", 1) ;_WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GUIRegisterMsg($WM_PAINT, "_Draw") GUISetState() While GUIGetMsg() <> -3 WEnd Func _Draw() _WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) EndFunc ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
hounder Posted May 6, 2010 Author Share Posted May 6, 2010 hounder you need to do different things. Like here: ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include <WindowsConstants.au3> #include <WinAPI.au3> Global $hGui = GUICreate("") Global $hDC = _WinAPI_GetDC($hGui) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX $pIcon = @WindowsDir & '\system32\cmd.exe' $iconStruct = DllStructCreate("int Handle") _WinAPI_ExtractIconEx($pIcon, 0, 0, DllStructGetPtr($iconStruct), 1) $hIcon = DllStructGetData($iconStruct, "Handle", 1) ;_WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GUIRegisterMsg($WM_PAINT, "_Draw") GUISetState() While GUIGetMsg() <> -3 WEnd Func _Draw() _WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) EndFunc ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXX alright, now how do i go about using winapi_drawiconex to draw a standalone icon file? ive got an icon in my script folder that i want it to draw, lets say its called "favicon.ico". Link to comment Share on other sites More sharing options...
trancexx Posted May 6, 2010 Share Posted May 6, 2010 alright, now how do i go about using winapi_drawiconex to draw a standalone icon file? ive got an icon in my script folder that i want it to draw, lets say its called "favicon.ico".What exactly is the problem? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
hounder Posted May 6, 2010 Author Share Posted May 6, 2010 What exactly is the problem? heres my current code, $pIcon = @WindowsDir & '\system32\cmd.exe' $iconStruct = DllStructCreate("int Handle") _WinAPI_ExtractIconEx($pIcon, 0, 0, DllStructGetPtr($iconStruct), 1) $hIcon = DllStructGetData($iconStruct, "Handle", 1) _WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) cant quite seem to figure out how to draw one of my own icons, instead of grabbing another icon from an .exe. IE. i want to draw "favicon.ico". help anyone? Link to comment Share on other sites More sharing options...
trancexx Posted May 6, 2010 Share Posted May 6, 2010 I was warned recently to stay on topic in threads like this. Lucky you. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Bert Posted May 6, 2010 Share Posted May 6, 2010 (edited) When you say "draw", do you mean create it from scratchcopy it from a existing iconextract it from an EXE that already existuse the icon file that already exist and tie it to a file so when I look at it, this is the icon it uses. none of the above - Please re-read my last post Edited May 6, 2010 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
hounder Posted May 6, 2010 Author Share Posted May 6, 2010 (edited) When you say "draw", do you mean create it from scratchcopy it from a existing iconextract it from an EXE that already existuse the icon file that already exist and tie it to a file so when I look at it, this is the icon it uses. none of the above - Please re-read my last postlet me know if this makes more sense of what im trying to do, Edited May 6, 2010 by hounder Link to comment Share on other sites More sharing options...
Bert Posted May 6, 2010 Share Posted May 6, 2010 (edited) OK, this is for a compiles script. Simple. when you go to compile your script, you tell the compiler what icon to use. look at my cokelocker script when compiled and running. Edited May 6, 2010 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
hounder Posted May 6, 2010 Author Share Posted May 6, 2010 OK, this is for a compiles script. Simple. when you go to compile your script, you tell the compiler what icon to use. look at my cokelocker script when compiled and running. heres my script, it doesnt use the standard GUI so i cant set an icon file the normal way. hence why im using the winapi draw functions to create the rest of the gui, im only assuming i can draw the icon aswell. expandcollapse popup#NoTrayIcon #include <WinAPI.au3> #include <String.au3> #include <Array.au3> #include <file.au3> #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <GUIButton.au3> #include <GuiStatusBar.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <SendMessage.au3> #include <Constants.au3> #include <FontConstants.au3> Global Const $SC_DRAGMOVE = 0xF012 Opt("MouseCoordMode", 2) Local $tMsg Opt("TrayMenuMode", 1) $frmMain = GUICreate("frmMain", 472, 329, 192, 124, $WS_POPUP, 0) GUISetBkColor(0xc2c2c2,$frmMain) GUISetState(@SW_SHOW) $rgn = _WinAPI_CreateRoundRectRgn(0, 0, 472, 329, 3, 3) _WinAPI_SetWindowRgn($frmMain, $rgn) DrawBar() While 1 $tMsg = TrayGetMsg() Switch $tMsg Case $TRAY_EVENT_PRIMARYDOWN GUISetState(@SW_SHOW) DrawBar() WinSetState("frmMain", "", @SW_RESTORE) Opt("TrayIconHide", 1) EndSwitch $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN $mPos = MouseGetPos() If $mPos[1] <= 20 Then If $mPos[0] >= 432 And $mPos[0] <= 444 Then GUISetState(@SW_HIDE) Opt("TrayIconHide", 0) ElseIf $mPos[0] >= 445 And $mPos[0] <= 471 Then Exit Else _SendMessage($frmMain, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndIf EndIf EndSwitch WEnd Func Hwid() $OSLang = StringLeft(@OSLang, 3) $OSVersion = StringRight(@OSVersion, 2) $Id = ($OSLang & "-" & $OSVersion & "-" & @OSBuild & "-" & @OSArch) Return _StringEncrypt(1, $ID, @UserName) ;MsgBox(0, "Unique ID", Hwid()) EndFunc Func DrawBar() Local $aDim = WinGetClientSize($frmMain) Local $hDC = _WinAPI_GetDC($frmMain) ; Bar Local $hBrush = _WinAPI_CreateSolidBrush(0xe6e6e6) Local $hRect = DllStructCreate($tagRECT) DllStructSetData($hRect,"Left",0) DllStructSetData($hRect,"Top",0) DllStructSetData($hRect,"Right",$aDim[0]) DllStructSetData($hRect,"Bottom",20) _WinAPI_FillRect($hDC,DllStructGetPtr($hRect),$hBrush) _WinAPI_DeleteObject($hBrush) ; Title $hFont = _WinAPI_CreateFont(17, 0, 0, 0, 700, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Verdana') $hOldFont = _WinAPI_SelectObject($hDC, $hFont) _WinAPI_SetTextColor($hDC, 0x33383e) _WinAPI_SetBkMode($hDC, $TRANSPARENT) _WinAPI_DrawText($hDC, " NOD", $hRect, $DT_LEFT) ; Icon $pIcon = @WindowsDir & '\system32\cmd.exe' $iconStruct = DllStructCreate("int Handle") _WinAPI_ExtractIconEx($pIcon, 0, 0, DllStructGetPtr($iconStruct), 1) $hIcon = DllStructGetData($iconStruct, "Handle", 1) _WinAPI_DrawIconEx($hDC, 7, 1, $hIcon, 16, 16) ; Minimize $hBrush = _WinAPI_CreateSolidBrush(0x33383e) DllStructSetData($hRect,"Left",$aDim[0]-37) DllStructSetData($hRect,"Top",12) DllStructSetData($hRect,"Right",$aDim[0]-28) DllStructSetData($hRect,"Bottom",14) _WinAPI_FillRect($hDC,DllStructGetPtr($hRect),$hBrush) _WinAPI_DeleteObject($hBrush) ; Close Local $hPen = _WinAPI_CreatePen($PS_SOLID,2,0x33383e) Local $hSelected = _WinAPI_SelectObject($hDC,$hPen) _WinAPI_DrawLine($hDC,$aDim[0]-20, 5, $aDim[0]-11, 14) _WinAPI_DrawLine($hDC,$aDim[0]-20, 14, $aDim[0]-11, 5) _WinAPI_SelectObject($hDC,$hSelected) _WinAPI_DeleteObject($hPen) $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3) ; Frame Edge $hBrush = _WinAPI_CreateSolidBrush(0xe6e6e6) DllStructSetData($hRect,"Left",$aDim[0]-2) DllStructSetData($hRect,"Top",20) DllStructSetData($hRect,"Right",$aDim[0]) DllStructSetData($hRect,"Bottom",$aDim[1]) _WinAPI_FillRect($hDC,DllStructGetPtr($hRect),$hBrush) DllStructSetData($hRect,"Left",0) DllStructSetData($hRect,"Top",20) DllStructSetData($hRect,"Right",1) DllStructSetData($hRect,"Bottom",$aDim[1]) _WinAPI_FillRect($hDC,DllStructGetPtr($hRect),$hBrush) DllStructSetData($hRect,"Left",0) DllStructSetData($hRect,"Top",$aDim[1]-1) DllStructSetData($hRect,"Right",$aDim[0]) DllStructSetData($hRect,"Bottom",$aDim[1]-2) _WinAPI_FillRect($hDC,DllStructGetPtr($hRect),$hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($frmMain,$hDC) AdlibRegister("DrawBar") EndFunc Link to comment Share on other sites More sharing options...
Bert Posted May 6, 2010 Share Posted May 6, 2010 (edited) OK, now I see your problem. I compiled your script and used a different Icon. For the EXE I see the Icon I used. When I ran your script, I see the command prompt icon in the upper corner. OK, I will have to see what can be done about this. Edited May 6, 2010 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now