CompuServe Thread

#Windows Calla

7 messages in this thread
#2949From: Chester L. KlossOct 14, 1991 10:34 AM
This is an Elementary question from a new Visual Basic User. I have written a tiny VB program that consists of three Horz. Scroll bars that correspond to red,green and blue. As you might expect, when you move the little box on the bar, the color of the form changes. I know its not much but to be able to control the form so easily is really neat. The next step is to have this program control the color of the windows desktop backgroud. I believe the windows call goes something like this: SetSysColors(nChanges,lpSysColor,lpColorValues) I believe lpSysColor would refer to the COLOR_BACKGROUND index in my case. My limited knowledge suggests that I need to declare this windows call somehow in the General section but I'm basically stuck there. Any suggestions ? Thanks, Chet There are 2 Replies.
#2974From: Costas KitsosOct 14, 1991 11:37 AM
Chet, In the General/Declarations section you need to Declare the procedure: Declare Sub SetSysColors Lib "User" (ByVal nChanges As Integer, ByVal lpSysColor As Integer, ByVal lpColorValues As Long) Type the above all on one line. BTW, if you haven't already done so, you should download WINAPI.ZIP from library 5. It contains the API function and procedure declarations for Visual Basic. Hope this helps. Costas There is 1 Reply.
#2991From: Chester L. KlossOct 14, 1991 12:51 PM
Thank you Costas, I will download WINAPI.ZIP, sounds like something I need. If I may impose on you again, While I understand the declaration, how do the RGB values get passed to Windows ? Do I then call this subroutine like I called the one I had written (DoColor) ? ………Chet There is 1 Reply.
#2999From: Costas KitsosOct 14, 1991 1:29 PM
Chet, I admit I haven't played much with SetSysColors. I took a look at the reference and discovered that lpSysColor and lpColorValues can accept arrays of integers and longs. So, the correct declaration would be: Declare Sub SetSysColors Lib "User" (ByVal nChanges As Integer, lpSysColor As Integer, lpColorValues As Long) nChanges is the number of colors to be changed, e.g. 2. lpSysColor is an array of integers of the elements to be changed, e.g. ReDim MyColor%(2) MyColor%(1) = COLOR_WINDOWTEXT MyColor%(2) = COLOR_CAPTIONTEXT lpColorValues is an array of long integers with the new RGB values, e.g. ReDim MyRGB&(2) MyRGB&(1) = &H0000FFFF& MyRGB&(2) = &H00C0C000& With the above example, you'd call SetSysColors like: SetSysColors 2, MyColor%(1), MyRGB&(1) When passing arrays of integer type you only need to specify the first member of the array. Costas There is 1 Reply.
#3052From: Chester L. KlossOct 14, 1991 6:04 PM
Thank you for your time Costas. You have got me off to a good start. It will be a good learning experience. thanks, ……….Chet
#3196From: Don FunkOct 15, 1991 10:45 AM
Hi Chester, The lpColorValues is a pointer to an array of integers that specify the RGB colors. You would have to fill this array *before* you made this call. The SetSysColors will not do this for you. Don Funk There is 1 Reply.
#3231From: Chester L. KlossOct 15, 1991 12:48 PM
Thanks Don. Maybe thats why I'm getting those UAE's