March 28, 2024, 08:36:02 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


DLL creation

Started by Brian, September 05, 2018, 05:28:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Larry,

It's included on a previous post under this topic in zip file birthday.zip (186.73 kB)

Brian

fasecero

If you do not want any edge use a static. The subclass is optional to change the cursor when the mouse is over the control.


$include "windowssdk.inc"
$INCLUDE "Commctrl.inc"
$include "cfImages.inc"

WINDOW win
UINT hCake
INT subclassID = 12345

OPENWINDOW win,0,0,640,480,@MINBOX|@MAXBOX|@SIZE,0,"PNG as button",&win_handler
SETWINDOWCOLOR win,RGB(200,255,200)

hCake=Load_PNG_FromFile(GETSTARTPATH+"birthday cake.png",100,100,0xFFC8FFC8)
SHOWIMAGE win,hCake,@IMGBITMAP,270,50,100,100

CONST STATIC_1=1
CONTROL win,@STATIC,"",265,201,104,104,0x50000000,STATIC_1
StaticSetImage(win,STATIC_1,hCake)
SetWindowSubclass(GetDlgItem(win.hwnd, STATIC_1), &subclassStaticProc, subclassID, 0)

WAITUNTIL ISWINDOWCLOSED(win)
DELETEIMAGE hCake,@IMGBITMAP
RemoveWindowSubclass(GetDlgItem(win.hwnd, STATIC_1), &subclassStaticProc, subclassID)
END

SUB win_handler(),INT
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW win
CASE @IDCLOSEWINDOW
CLOSEWINDOW win
CASE @IDCONTROL
SELECT @CONTROLID
CASE STATIC_1
IF @NOTIFYCODE = 0
SETCAPTION(win,"You have just clicked the static")
ENDIF
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB

SUB subclassStaticProc(hWnd:INT,uMsg:INT,wParam:INT,lParam:INT,uIdSubclass:UINT_PTR,dwRefData:DWORD_PTR),INT
SELECT uMsg
CASE WM_SETCURSOR
WINDOW w
w.hwnd = hWnd
SETCURSOR(w, @CSCUSTOM, LoadCursor(NULL, IDC_HAND))
RETURN TRUE
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

SUB StaticSetImage(WINDOW w,INT id,INT image)
INT handle=GetDlgItem(w.hWnd,id)
LONG style=GetWindowLong(handle,GWL_STYLE)
style=style|SS_BITMAP|SS_NOTIFY
SetWindowLong(handle,GWL_STYLE,style)
_SendMessage(handle,STM_SETIMAGE,IMAGE_BITMAP,image)
ENDSUB


Brian

Well, we are learning some stuff at the moment! Works well here, as does all your code

Many thanks,

Brian

fasecero

Also, if we want to complicate things even more :) we can make an OWNERDRAW button that uses a different image for each state: normal, over, pressed.


$include "windowssdk.inc"
$INCLUDE "Commctrl.inc"
$include "cfImages.inc"

WINDOW win
UINT hCake,hCakeOver,hCakePressed
INT subclassID = 12345
INT isOverButton = 0

OPENWINDOW win,0,0,640,480,@MINBOX|@MAXBOX|@SIZE,0,"PNG as button",&win_handler
SETWINDOWCOLOR win,RGB(200,255,200)

hCake=Load_PNG_FromFile(GETSTARTPATH+"birthday cake normal.png",140,140,0xFFC8FFC8)
hCakeOver=Load_PNG_FromFile(GETSTARTPATH+"birthday cake over.png",140,140,0xFFC8FFC8)
hCakePressed=Load_PNG_FromFile(GETSTARTPATH+"birthday cake pressed.png",140,140,0xFFC8FFC8)
SHOWIMAGE win,hCake,@IMGBITMAP,270,50,140,140

' method #2
CONST BUTTON_1 = 1
CONTROL win,@SYSBUTTON,"",265,201,140,140,0x50000000,BUTTON_1
ButtonSetImages(win, BUTTON_1)
SetWindowSubclass(GetDlgItem(win.hwnd, BUTTON_1), &subclassButtonProc, subclassID, 0)

WAITUNTIL ISWINDOWCLOSED(win)
DELETEIMAGE hCake,@IMGBITMAP
DELETEIMAGE hCakeOver,@IMGBITMAP
DELETEIMAGE hCakePressed,@IMGBITMAP
RemoveWindowSubclass(GetDlgItem(win.hwnd, BUTTON_1), &subclassButtonProc, subclassID)
END

SUB win_handler(),INT
SELECT @MESSAGE
CASE WM_SETCURSOR
isOverButton = 0
RedrawWindow(GetDlgItem(win.hwnd, BUTTON_1), NULL, NULL, RDW_INVALIDATE)
CASE @IDCREATE
CENTERWINDOW win
CASE @IDCLOSEWINDOW
CLOSEWINDOW win
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
SETCAPTION(win,"You have just clicked the button")
ENDIF
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB

SUB subclassButtonProc(hWnd:INT,uMsg:INT,wParam:INT,lParam:INT,uIdSubclass:UINT_PTR,dwRefData:DWORD_PTR),INT
SELECT uMsg
CASE WM_SETCURSOR
isOverButton = 1
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE)
WINDOW w
w.hwnd = hWnd
SETCURSOR(w, @CSCUSTOM, LoadCursor(NULL, IDC_HAND))
RETURN TRUE
CASE WM_DRAWITEM
IF *<DRAWITEMSTRUCT>lParam.itemState & ODS_DEFAULT THEN
DrawButtonImage(*<DRAWITEMSTRUCT>lParam.hDC, hCake, 0, 0, *<DRAWITEMSTRUCT>lParam.rcItem.right, *<DRAWITEMSTRUCT>lParam.rcItem.bottom)
ELSEIF *<DRAWITEMSTRUCT>lParam.itemState & ODS_SELECTED THEN
DrawButtonImage(*<DRAWITEMSTRUCT>lParam.hDC, hCakePressed, 0, 0, *<DRAWITEMSTRUCT>lParam.rcItem.right, *<DRAWITEMSTRUCT>lParam.rcItem.bottom)
ELSEIF isOverButton THEN
DrawButtonImage(*<DRAWITEMSTRUCT>lParam.hDC, hCakeOver, 0, 0, *<DRAWITEMSTRUCT>lParam.rcItem.right, *<DRAWITEMSTRUCT>lParam.rcItem.bottom)
ELSE
DrawButtonImage(*<DRAWITEMSTRUCT>lParam.hDC, hCake, 0, 0, *<DRAWITEMSTRUCT>lParam.rcItem.right, *<DRAWITEMSTRUCT>lParam.rcItem.bottom)
ENDIF
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

SUB ButtonSetImages(WINDOW w, INT id)
INT handle = GetDlgItem(w.hwnd, id)
LONG style = GetWindowLong(handle,GWL_STYLE)
style = WS_CHILD | WS_VISIBLE | BS_OWNERDRAW
SetWindowLong(handle,GWL_STYLE,style)
_SendMessage(handle, WM_CHANGEUISTATE, MAKELONG(UIS_SET, UISF_HIDEFOCUS), 0)
ENDSUB

SUB DrawButtonImage(INT hDC, UINT hbit, INT x, INT y, INT width, INT height) ' alpha: 1 to 255
HDC hdcMem = CreateCompatibleDC(hDC)
    HBITMAP hbmOld = SelectObject(hdcMem, hbit)
BITMAP bm
GetObject(hbit, LEN(bm), &bm)
    StretchBlt(hDC, x, y, width, height, hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY)
    SelectObject(hdcMem, hbmOld)
    DeleteDC(hdcMem)
ENDSUB



Brian

And another one bites the dust! How did you do the "glow" effect? I used paint.net, which had the birthday cake as a shape, and then I added the colours, and saved it as a PNG. Very useful program, and there are a lot of plugins for it

Brian

fasecero

I have a very old copy of photoshop (I think it's a version more than 10 years old that was given for free for a limited time by adobe). I also have an old embarcadero that was given for free also, but I never liked delphi so I never touched it. I have heard good things from Paint.net, also for GIMP as alternatives. I did a kick search and found this short video to make a glow in paint.net, maybe it can help, my advice watch the video without sound, the music is terrible: https://www.youtube.com/watch?v=BR6BxROSPDg

Brian

Fasecero,

I remember the Photoshop giveaways. In the UK, you could buy a magazine with a CD inside, containing the full version (7, I think), no limitations, private or business use. Got to be over 10 years ago, now. Although it wasn't easy to update them later

My money-conscious MD asked me to take some money out of the petty cash, and go and buy 10 copies. I think we cleaned the town centre shops out!

I tried GIMP a few years ago, and found it very slow. I have the latest version now, and it has speeded up tremendously, although I don't think it is very friendly. Maybe I don't use it enough to give it a fair comment

Brian

fasecero

There was a magazine with a CD-ROM many years ago â€" so long ago I don't remember the name, it was cheap and was filled with lots of shareware and freeware programs. At that time I still didn't have internet at home so I spent hours installing apps. In there I found out by pure chance a program called darkbasic that was able to make games, so I began to program. I was very bad at making games lol so I start to ask myself how traditional programs were made. Can't remember what I wrote in google but Creative Basic was the first result I got. MSDN guided me to study some c, but I only feel comfortable writting code with our tools in here :) Anyway sorry to get off track. I'm now interested in making a button with a glow effect, I mean with a transition or animation, no idea what it takes so we'll see

Brian

There are some plugins for paint.net which includes a button maker - it's pretty good and easy. So easy, even I made one!

https://forums.getpaint.net/topic/7186-madjik-all-plugins-last-updated-2018-04-07/

Brian

h3kt0r

Thanx for sharing this !

Found this site some time ago :



Quote
Who knew that the companies looking for a quick buck through the late 1980's and early 1990's with "Shovelware" CDs would become the unwitting archivists of the BBS age? No one did, but here we are, looking back, muttering thanks to these souless con artists as we plunder the very data they themselves took from a time now past.

if you're looking for some oldies sharewares then, this is the place to go...