You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
This is a simple and not profi example but works:
SendMessage( hgWin, %WM_SETICON, %ICON_BIG, LoadIcon( 0, ByVal %IDI_EXCLAMATION ) )
SendMessage( hgWin, %WM_SETICON, %ICON_SMALL, LoadIcon( 0, ByVal %IDI_EXCLAMATION ) )
Notes:
You should use LoadImage() and use real big *and* small icons.
Custom icon handles should be freed.
Any ideas on how to create/display a custom icon on the caption line?
Looks like it isn't normally possible to change the icon of a Graphic Window. Here's a technique though for setting the icon while the window is being created..
Code:
#DIM ALL
#INCLUDE "WIN32API.INC"
GLOBAL hHook???
FUNCTION HookGFXWindow(BYVAL lMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
DIM hIcon???
IF lMsg = %HCBT_CREATEWND THEN ' wParam has handle of Window about to be created
UnhookWindowsHookEx hHook
'hIcon = LoadImage(BYVAL %NULL, "Objects.ico", %IMAGE_ICON, 16, 16, %LR_LOADFROMFILE ) ' your icon
hIcon = LoadIcon(BYVAL %NULL, BYVAL %IDI_EXCLAMATION) ' std icon - comment out if using your own
SetClassLong wParam, %GCL_HICONSM, hIcon
END IF
FUNCTION = 0
END FUNCTION
'------------------/HookGFXWindow
FUNCTION PBMAIN()
DIM gWdw???
hHook = SetWindowsHookEx(%WH_CBT, CODEPTR(HookGFXWindow), GetModuleHandle(""), 0)
GRAPHIC WINDOW "Test GFX Window", 200, 200, 350, 200 TO gWdw
GRAPHIC ATTACH gWdw, 0
GRAPHIC PRINT
GRAPHIC PRINT " Window title can be a string literal or an asciiz string (variable)"
SLEEP 1000
SetWindowText gWdw, "** Check out the fancy Icon ! **" ' <- String literal works ok here
GRAPHIC WAITKEY$
GRAPHIC WINDOW END
END FUNCTION
'------------------/PBMain
Hello Doug, that example is an windows API, but it will work in pbcc graphics, you'll have to include the windows api like I'm showing. I'm using the Same example from last time.
Code:
#COMPILE EXE
#DIM ALL
#INCLUDE "C:\PBCC40\WINAPI\WIN32API.INC"
FUNCTION PBMAIN () AS LONG
LOCAL NewCaption AS ASCIIZ * 40
LOCAL hGWin AS DWORD
LOCAL t AS STRING
GRAPHIC WINDOW "Undraw test...",0,0,800,600 TO hgwin
GRAPHIC ATTACH hGWin, 0, REDRAW
NewCaption = "Howdy Folks"
SetWindowText(hgWin, NewCaption)
GRAPHIC SET POS (200,300)
GRAPHIC PRINT "Now is the time for all good men to come to the aid of their country"
GRAPHIC SET POS (200,340)
GRAPHIC PRINT "The quick red fox jumped over the lazy dogs back many times."
GRAPHIC SET POS (200,380)
GRAPHIC PRINT "Now is the time for all good men to come to the aid of their country"
GRAPHIC REDRAW
SLEEP 3000
GRAPHIC SET MIX %MIX_NOTXORSRC
GRAPHIC LINE (200,200)-(600,500)
GRAPHIC REDRAW
SLEEP 4000
GRAPHIC LINE (200,200)-(600,500)
GRAPHIC REDRAW
' restore the default mode...
GRAPHIC SET MIX %MIX_COPYSRC
GRAPHIC SET FOCUS
NewCaption = "Goodbye Friends"
SetWindowText(hgWin, NewCaption)
SLEEP 4000
GRAPHIC WINDOW END
END FUNCTION
Could you show the code, or something compilable that you think would work but doesn't.
If you are doing something wrong someone will find it, and/or if there is an issue it can be documented(sent to support).
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: