Announcement
Collapse
No announcement yet.
ButtonPlus in Source Code
Collapse
X
-
New problem. One column in a listview won't come through when i use the DDT LISTVIEW GET TEXT hndl, id, 1,6 to stxt. All the other columns work, all are TEXT columns and this column has a file location in it: "C:\folder\subfolder\filename.ext" in it and is the only column that goes though button plus when I trace it. The stxt is empty when Button Plus is done. I don't know whey this column goes through button plus when the others do not. I do not set color of this column different than others at all.
-
-
Originally posted by Michael Mattias View PostWhat you describe is the "valid" situation.
I am thinking of all the times I see "CONTROL anything CBHNDL..." on a window/control NOT created by DDT (or created with CONTROL ADD "classname").
Those calls may 'work'; they may not. They may even work today but not tomorrow.
MCM
Leave a comment:
-
-
What you describe is the "valid" situation.
I am thinking of all the times I see "CONTROL anything CBHNDL..." on a window/control NOT created by DDT (or created with CONTROL ADD "classname").
Those calls may 'work'; they may not. They may even work today but not tomorrow.
MCM
Leave a comment:
-
-
Originally posted by Michael Mattias View Post>Try it [before] you cay it can't be done
I'm not saying things "can't be done" in the sense they might "work today;" I am saying they are not supported, and if they stop "working" in the next release of either the operating system or compiler, be neither surprised, disappointed or whiney.
MCM
Leave a comment:
-
-
>Try it [before] you cay it can't be done
I'm not saying things "can't be done" in the sense they might "work today;" I am saying they are not supported, and if they stop "working" in the next release of either the operating system or compiler, be neither surprised, disappointed or whiney.
MCM
Leave a comment:
-
-
So problem solved then Barry? (hope so, because I don't really understand what was happening!).
ButtonPlus is most definitely designed to work with DDT since I myself only resort to the API when I have to. I must admit that I haven't yet had occasion to use BP with PB10 though.
Leave a comment:
-
-
The problem was I was saving the value of the text box as -2 instead of -1 for system.
ANd you can mix DDT with other things and button plus uses sdk, which I have mixed with DDT for years. The CONTROL HANDLE allows pointing to the item for the sdk. And Button plus is designed to be used with DDT buttons. Since you do not use DDT, you can't see the weird thing by seeting a text background to -2 and passing your mosue over it.
Anyway, it is working fine mixing DDT with sdk. And you can use sdk mixed with DDT controls if there is not a compatible ddt thing. I sid that for listview sort numeric back when 10.00 came out and it's DDT did not work. And originally used the sdk for listview stuff before PB had it. And I still mix progress bar ddt with progressbar sdk.
Try it beofre you cay it can't be done.
Leave a comment:
-
-
>and mixing buttonPlus with Control set color
Does Button Plus create DDT-managed controls? If not, there's your problem: CONTROL SET COLOR was designed for use with DDT-managed controls.
Besides, even CONTROL SET COLOR is not meant for buttons:
Restrictions
Windows does not permit the color of standard push button controls, line controls, image controls, image buttons, and most common controls to be altered by the standard CONTROL SET COLOR techniques.
Leave a comment:
-
-
I have a weird problem when using this with PBWin10 and mixing buttonPlus with Control set color for lables and textboxes. A non-colorized or touched by code in ButtonPlus calls or Control Set Color end up in some textboxes when ButtonPlus is being used during WM_INITDIALOG or moving the mouse over a text box. Have you ever seen this? I do not have any weird ID's duplicate or do I set the checkbox twice. ANd if I do not colorize one text, with control set color , the problme will move to the next textbox.
I will try to bring this down to a small example and post it.
Leave a comment:
-
-
LJ, I think there may be a problem in BP. I was playing around with Scott Slater's Butons in Listbox (neat idea) - http://www.powerbasic.com/support/pb...ad.php?t=40672 -
And when I added BP, trying to scroll (see thread above) I would get a bunch of Error 9's. It didn't happen with Chris' code so that's what I posted there.
The E9's went away when I commented out the %WM_VScroll in scott's first version.
Code:'http://www.powerbasic.com/support/pbforums/showthread.php?t=40672 'scott Slater #Compile Exe #Dim All #Optimize SPEED 'Fly baby Fly!!! #Debug Display On '<<<<<<<<<<<<<<< Remember to turn off for production code #Include "win32api.inc" 'these next included files needed for button colors can be found here: 'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904 #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas" '#Resource "C:\Only_My_Programs\Include Files\ButtonPlusDemo.pbr" Global gOldLBProc As Dword ' ' ******************************************************* ' Function Btn_Set_Face_Color(ddlg As Dword, Id As Long, Btn_Color As Long) As Long ButtonPlus ddlg, Id, %BP_FACE_BLEND, 255 'true color ButtonPlus dDlg, Id, %BP_FACE_COLOR, Btn_Color ' &H008FDF8F End Function ' Function Btn_Set_Text_Color(ddlg As Dword, Id As Long, Btn_Color As Long) As Long ButtonPlus dDlg, Id, %BP_Text_COLOR, Btn_Color ' &H008FDF8F End Function ' ' ******************************************************* ' Function BtnLBproc(ByVal hWnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Local rc As RECT Select Case wMsg Case %WM_Command If wParam > 200 Then 'Button ids GetClientRect hWnd, rc ' ' ******************************************************* ' Btn_Set_Face_Color(hwnd, Wparam, %Black + 1) Btn_Set_Text_Color(hwnd, Wparam, %Yellow) Control ReDraw hwnd, Wparam ' MessageBox hWnd, "Button " & Format$(wParam - 200) & " clicked", "Button Click", 0 ' ' ******************************************************* ' End If Case %WM_SETFONT ' Don't accept font messages for this control Exit Function Case %WM_DrawItem ' Redraw entire listbox area GetClientRect hWnd, rc InvalidateRect hWnd, rc, 1 Case %WM_VScroll ' Redraw after scrolling SendMessage hWnd, %WM_DrawItem, wParam, lParam '<<<<<<< crashes here - Error 9's with SendMessage '>>>>>>>>> Scrolls fine without but only scroll 10 buttons, not all 25 End Select Function = CallWindowProc(gOldLBProc, hWnd, wMsg, wParam, lParam) 'process other messages End Function CallBack Function MainDlgProc Select Case CB.Msg Case %WM_Destroy SetWindowLong GetDlgItem(CB.Hndl,100), %GWL_WNDPROC, gOldLBProc ' unhook: restore original callback Case %WM_Command Select Case CB.Ctl Case %IdCancel Dialog End CbHndl End Select End Select End Function Function PBMain () As Long Local hDlg, hLst, hFnt, BtnID, YPos As Long Local n, Btn_Face_Color, Btn_Text_Color As Long Font New "Ariel", 10 To hFnt Dialog New 0, "Test Button List",,, 100, 140 To hDlg Control Add ListBox, hDlg, 100, , 10, 10, 75, 115, %WS_Child Or %LBS_NoSel Or _ %WS_TabStop Or %LBS_DisableNoScroll Or %WS_VScroll, %WS_Ex_ClientEdge ' use %LBS_NOSEL to prevent selecting "text area" Control Set Font hDlg, 100, hFnt ' set the font, so that the height is the will contain the added buttons; should use FontIndirect Control Handle hDlg, 100 To hLst ' listbox handle for hook gOldLBProc = GetWindowLong(hLst, %GWL_WNDPROC) ' save original LB Callback SetWindowLong hLst, %GWL_WNDPROC, CodePtr(BtnLBproc) ' assign our Callback so we can intercept messages. ' add some buttons to the listbox area: parent dialog for buttons is hLst YPos = 2 For BtnID = 201 To 225 Control Add Button, hLst, BtnID, "Button " & Format$(BtnID-200), 5, YPos, 80, 28 ' ' ******************************************************* ' 'set button colors Incr n If n > 3 Then n = 1 Select Case n Case 1 Btn_Face_Color = %Red Btn_Text_Color = %White Case 2 Btn_Face_Color = %White Btn_Text_Color = %Blue Case 3 Btn_Face_Color = %Blue Btn_Text_Color = %White End Select ' Btn_Face_Color = %Red ' Btn_Text_Color = %White Btn_Set_Face_Color(Hlst, BtnId, Btn_Face_Color) Btn_Set_Text_Color(Hlst, BtnId, Btn_Text_Color) ListBox Add hDlg, 100, " " YPos += 32 Next BtnID ' ' ******************************************************* ' Control Add Button, hDlg, %IdCancel, "Close", 25, 117, 50, 20 Dialog Show Modal hDlg Call MainDlgProc Font End hFnt End Function
==================================================
Certainly virtue is like precious odors,
most fragrant when they are incensed, or crushed:
for prosperity doth best discover vice,
but adversity doth best discover virtue.
Sir Francis Bacon
==================================================
Leave a comment:
-
-
"Complaining" was just a poor choice of words, sorry! In your original example, I DID see the white spot when the button was pressed, but it was partially off the top of the button. Because it was a small vertical ellipse, it looked a bit wierd, but it was there.
Leave a comment:
-
-
Originally posted by Laurence Jackson View Post"...couldn't get it to work..." How did it fail? Your code seems to be working to me, so I need a bit more.
If you are complaining about the spot sliding off the top of the button, that's by design to allow effects other than a circular or elliptical blob of color. The rules are not fully explained in the doc - sorry about that. Basically, if you want the whole spot on the button face, specify a smaller size and avoid TOP or BOTTOM.Code:ButtonPlus hDlg, Id, %BP_SPOT_WIDTH, 8'16 ButtonPlus hDlg, Id, %BP_SPOT_HEIGHT, 10'20
Updated:
http://www.swedesdock.com/powerbasic/Btn_Demo_using_Arrays.exe
(Note for some reason editor won't allow entire link here. You'll have to C&P it into your browser or use the one in a prv msg)
Thx again.Last edited by Gösta H. Lovgren-2; 1 Jun 2009, 08:51 PM.
Leave a comment:
-
-
"...couldn't get it to work..." How did it fail? Your code seems to be working to me, so I need a bit more. If you are complaining about the spot sliding off the top of the button, that's by design to allow effects other than a circular or elliptical blob of color. The rules are not fully explained in the doc - sorry about that. Basically, if you want the whole spot on the button face, specify a smaller size and avoid TOP or BOTTOM.
Yes, you're right. In the doc:
ButtonPlus hDlg, %IDC_BUTTON, %BP_SPOT_POS, %TOP + %LEFT
should be changed to:
ButtonPlus hDlg, %IDC_BUTTON, %BP_SPOT_POS, %BS_TOP + %BS_LEFT
Leave a comment:
-
-
Laurence, I fooled with the Spot stuff tonight but just couldn't get it to work {sigh}. Here's the code I tried (note correction needed in docs). The full code is attached.
Code:' Macro Btn_Spot ButtonPlus hDlg, Id, %BP_SPOT_COLOR, %White '%Red ButtonPlus hDlg, Id, %BP_SPOT_BLEND, &HFF ButtonPlus hDlg, Id, %BP_SPOT_WIDTH, 16 ButtonPlus hDlg, Id, %BP_SPOT_HEIGHT, 20 ButtonPlus hDlg, Id, %BP_SPOT_POS, %BS_TOP + %BS_Left '<-- incorrect in docs - no BP_ for Top or Left End Macro '
Here's a link to the exe http://www.swedesdock.com/powerbasic...ing_Arrays.exe
{Note I also colored the buttons in the Unicode example. Took all of five minutes to do. And most of them were consumed in testing artistic color choices. {grin}))
===========================================================
"The reasonable man adapts to the world:
The unreasonable man persists
in trying to adapt the world to himself.
Therefore, all progress depends upon the unreasonable man."
-- George Bernard Shaw
===========================================================Attached FilesLast edited by Gösta H. Lovgren-2; 31 May 2009, 10:20 PM. Reason: Executions, Execitement, exefun, ...
Leave a comment:
-
-
Originally posted by Laurence Jackson View PostButtons face colors have a default 50% transparency basically for the same reason as Windows normally colors buttons some shade of gray and not black or white. I'll quote myself:
"First, primary colors on button faces tends to be a bit overpowering and gaudy. Second, when using XP-themed buttons, some degree of transparency is necessary to retain the proper effect of the buttons being pressed."
As I said in the source code, José Roca really deserves the credit for much of what is in there. All I really did is package it up (I do take credit for "the spot" though!).
Again, thx for BP, LJ.
======================
Different values make
for a richer world.
Unknown
======================
Leave a comment:
-
-
Buttons face colors have a default 50% transparency basically for the same reason as Windows normally colors buttons some shade of gray and not black or white. I'll quote myself:
"First, primary colors on button faces tends to be a bit overpowering and gaudy. Second, when using XP-themed buttons, some degree of transparency is necessary to retain the proper effect of the buttons being pressed."
As I said in the source code, José Roca really deserves the credit for much of what is in there. All I really did is package it up (I do take credit for "the spot" though!).
Leave a comment:
-
-
Originally posted by Laurence Jackson View Post...The other colors are not wrong, just subdued (alpha-blended with the underlying face color).
Again I love ButtonPlus and am not criticizing (well maybe just a tad). It's so good I wouldn't be surprised to see some form of it be a part of PBWin10.
============================================
People will not remember
what you did or what you said.
People will remember how you made them feel.
LadyHawke
============================================
Leave a comment:
-
-
Originally posted by Laurence Jackson View Post...
The other colors are not wrong, just subdued (alpha-blended with the underlying face color). Check out the %BP_FACE_BLEND parameter. If you want a solid face color, pass a %BP_FACE_BLEND value of 255. The default is 128, as explained in the text file.
If any are interested, here's some BP macros I just put together:
Code:'Corrected Bp_Face_Black macro May 31 ' '************************ ' Global bp_Hndl As Dword 'used for button coloring ' Global bp_ctl As Long 'used for button coloring Macro Bp_face_Black = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Black + 1 ' Macro Bp_face_Blue = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Blue Macro Bp_face_Green = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Green Macro Bp_face_Cyan = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Cyan Macro Bp_face_Red = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Red Macro Bp_face_Magenta = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Magenta Macro Bp_face_Yellow = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Yellow Macro Bp_face_White = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %White Macro Bp_face_Gray = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %Gray Macro Bp_face_LtGray = Bp_No_Blend: ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_COLOR, %LtGray ' Macro Bp_text_Black = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Black Macro Bp_text_Blue = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Blue Macro Bp_text_Green = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Green Macro Bp_text_Cyan = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Cyan Macro Bp_text_Red = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Red Macro Bp_text_Magenta = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Magenta Macro Bp_text_Yellow = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Yellow Macro Bp_text_White = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %White Macro Bp_text_Gray = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %Gray Macro Bp_text_LtGray = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, %LtGray Macro Bp_text_Color = ButtonPlus bp_Hndl, bp_ctl, %BP_text_COLOR, Clor Macro Bp_No_Blend = ButtonPlus bp_Hndl, bp_ctl, %BP_FACE_BLEND, 255 '1-255 transparency '255=true color ' ' ******************************************************* '
High thoughts must have high language.
Aristophanes
======================================
Leave a comment:
-
-
%BLACK has a value of zero, which is being interpreted by ButtonPlus as "use or revert to the default". So, you have to use 1 or RGB(1,1,1) if you want black (or very close to it).
The other colors are not wrong, just subdued (alpha-blended with the underlying face color). Check out the %BP_FACE_BLEND parameter. If you want a solid face color, pass a %BP_FACE_BLEND value of 255. The default is 128, as explained in the text file.
Leave a comment:
-
-
JFF, I was playing around with button coloring this evening and came across an interesting phenomenon: The colors in ButtonPlus don't exactly translate; ie Red is Orange, Black is White, ... See sample:
'Code:'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3 #Dim All #Compile Exe #Optimize SPEED #Debug Display On'off for production code #Include "WIN32API.INC" #Include "COMDLG32.INC" #Include "InitCtrl.inc" ' 'these next included files can be found here: 'http://www.powerbasic.com/support/pbforums/showthread.php?t=38904 #Include "C:\Only_My_Programs\Include Files\ButtonPlus.bas" #Resource "C:\Only_My_Programs\Include Files\ButtonPlusDemo.pbr" %Button_Ids_Start_At = 1000 %Id_Exit_Btn = 2000 ' Global hdlg As Dword ' Macro Common_Locals 'Macro easier than retyping and maintains coding consistency Local Dlg_hght, Dlg_Wd As Long Local Btn_bg_Colors() As Long Local clor, Id, Stile, Row, col, hght, wd, Longest,ctr, ln, ln1, i As Long Local l, s As String Dim Btn_bg_Colors(1 To 10) Btn_bg_Colors(1) = %Black Btn_bg_Colors(2) = %Blue Btn_bg_Colors(3) = %Green Btn_bg_Colors(4) = %Cyan Btn_bg_Colors(5) = %Red Btn_bg_Colors(6) = %Magenta Btn_bg_Colors(7) = %Yellow Btn_bg_Colors(8) = %White Btn_bg_Colors(9) = %Gray Btn_bg_Colors(10) = %LtGray End Macro ' CallBack Function Dialog_Processor Common_Locals Select Case CbMsg 'This is TO determine the message TYPE ' Case %WM_INITDIALOG'<- Initialiaton when the program loads ' Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes ' Case %WM_COMMAND 'This processes command messages Select Case CbCtl Case %Id_Exit_Btn Select Case CbCtlMsg Case 0 Dialog End CbHndl 'Applikation beenden End Select End Select End Select End Function ' Function PBMain Common_Locals Stile = Stile Or %WS_CAPTION Stile = Stile Or %WS_SYSMENU Stile = Stile Or %WS_THICKFRAME Stile = Stile Or %WM_HELP Stile = Stile Or %WS_Border 'doesn't do anything Dlg_hght = 400 Dlg_Wd = 250 l$ = Space$(Dlg_Wd \ 8) CSet l$ = "Coloring Button Demo" Dialog New Pixels, hdlg, l$, , , Dlg_Wd, Dlg_Hght, Stile To hdlg 'centered Row = 10 col = 10 Wd = 100 Hght = 20 Stile = %ss_center For ctr = LBound(Btn_bg_Colors()) To UBound(Btn_bg_Colors()) Clor = Btn_bg_Colors(ctr) 'bg color to use Id = %Button_Ids_Start_At + ctr Control Add Label, hdlg, Id, "label", Col, Row, Wd, Hght, stile Control Set Color hdlg, Id, %White, Clor ' Control Add Button, hdlg, Id + 100, "Button", col + wd + 10, row, Wd, Hght, 0 'style must be 0 or 1 - see docs in ButtonPlus.bas ButtonPlus hDlg, Id + 100, %BP_FACE_COLOR, Clor Row = Row + Hght + 5 Next ctr hght = 25 Wd = Dlg_Wd - 20 Col = 10 'center Row = Dlg_hght - Hght - 2 'Just off bottom Control Add Button, hdlg, %Id_Exit_Btn, "Run Rabbit Run.", col, row, Wd, Hght ButtonPlus hDlg, %Id_Exit_Btn, %BP_FACE_COLOR, %Red ButtonPlus hDlg, %Id_Exit_Btn, %BP_Text_COLOR, %Yellow Dialog Show Modal hDlg Call Dialog_Processor End Function 'Applikation beenden '
Also the Btn_Demo (attached below) I first posted has a serious error. The Big Dummy had dimmed the bg colors() as integer instead of long. The colors still don't come out right (bug in MY code for certain, but dogged if I can find it). Problem is unrelated to anomaly above, though.
====================================
So often we rob tomorrow’s memories
by today’s economies.
John Mason Brown
====================================Attached Files
Leave a comment:
-
Leave a comment: