DOCUMENT:Q177081 25-NOV-1997 [vbwin] TITLE :BUG: Control Displays Dithered Background in 256-Color Mode PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0 OPER/SYS:WINDOWS KEYWORDS:vb5all VBKBAX VBKBComp VBKBCtrl ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0 --------------------------------------------------------------------- SYMPTOMS ======== A form using a custom palette dithers the background color of any control placed on the form when the project is run on a computer configured to display 256 colors. This symptom does not occur on a computer configured to display more than 256 colors. RESOLUTION ========== To work around this problem: - Run the Visual Basic program on a system configured to display more than 256 colors. -or- - Do not use a custom palette. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- NOTE: To reproduce this problem, your system display should be set to 256-color. 1. Start a new Standard EXE project in Visual Basic. Form1 is created by default. 2. Add a Frame control to Form1. 3. Set the following properties for Form1: Property Value -------- ----- Picture pastel.dib PaletteMode 1-UseZOrder The file pastel.dib is located in the Samples\PGuide\PalMode directory where you installed Visual Basic. 4. Copy the following code to the Code window of Form1: Option Explicit Private Sub Form_Load() Me.BackColor = RGB(24, 180, 164) Frame1.BackColor = RGB(24, 180, 164) End Sub 5. Press the F5 key to run the program and note that the Frame background appears dithered. REFERENCES ========== "Using Relative Palette Colors" topic in Readme.hlp For more information about Visual Basic and color palettes, please see the following article in the Microsoft Knowledge Base: ARTICLE-ID: Q74908 TITLE : SAMPLE: Using the Palette Under Windows Additional query words: display vga (c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Arsenio Locsin Microsoft Corporation <<>> 176951 <<>> 1 <<>> HOWTO: Use Events to Generate Asynchronous Callbacks <<<LONGTITLE>>> HOWTO: Use Events to Generate Asynchronous Callbacks <<<PRODUCT>>> vbwin <<<PRIORITY>>> 2 <<<SECURITY>>> PUBLIC <<<AUTHOR>>> smason <<<EDITOR>>> pjRiker <<<EDITSTATUS>>> Released <<<TECH>>> randyru <<<TECHSTATUS>>> Approved <<<EXPIREDATE>>> Dec 31 1999 12:00AM <<<MESSAGE>>> <<<KEYWORD>>> vb5all vb5howto <<<INTERNALADMIN>>> kbDSupport kbdse <<<QUESTION>>> <<<PRODVERNUM>>> WINDOWS:5.0 <<<COMPONENT>>> <<<TECHNOLOGY>>> kbole <<<LINKS>>> <<<RAIDINFO>>> <<<INCIDENT>>> <<<SWEEPDATE>>> <<<SWEEPSTATUS>>> <<<SOLUTIONTYPE>>> <<<ISSUETYPE>>> kbhowto <<<PLATFORM>>> WINDOWS <<<HARDWARE>>> x86 <<<BOILERPLATE>>> <<<PRODUCEDVIEW>>> <<<TEXT>>> --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0 --------------------------------------------------------------------- SUMMARY ======= In asynchronous processing, the method that starts a task is returned immediately without waiting for a result. The client can continue to do what it was originally doing while the task is completed. The server needs a way to notify the client asychronously when the task is done. One way of doing this is to create an event that the client will handle. MORE INFORMATION ================ Following is a code sample demonstrating how a client application can start another server application and wait for its completion notification via an event. Clicking the Start button on the client's form starts up an instance of the server and returns immediately. The server can then begin some long calculation or other work. Upon completion of the task, the server will fire the Notify event. The client receives this event and responds accordingly. Server Application ------------------ The server application is an ActiveX .exe file consisting of one class module (clsTimer) and one standard module. Set the instancing property of the Class module to Single Use. In the Project Properties dialog box, make sure that the Startup Object is set to None: clsTimer code Event Notify(ByVal somenum As Double) Public Sub StartTimer() Call BeginTimer(Me) 'Start the timer End Sub Public Sub Notifyme(ByVal anum As Double) RaiseEvent Notify(anum) 'Create an event with the result End Sub 'as a parameter Public Sub StopTimer() Call EndTimer End Sub Private Sub Class_Terminate() Call EndTimer 'Make sure the timer is stopped End Sub Standard module code: Global timerid As Long Dim thetimer As clsTimer Public Declare Function SetTimer Lib "user32" _ (ByVal hwnd As Long, _ ByVal nIDEvent As Long, _ ByVal uElapse As Long, _ ByVal lpTimerFunc As Long) As Long Public Declare Function KillTimer Lib "user32" _ (ByVal hwnd As Long, _ ByVal nIDEvent As Long) As Long Public Sub EndTimer() Dim retval As Long retval = KillTimer(0, timerid) End Sub Public Sub BeginTimer(ByRef Timerobj As clsTimer) Set thetimer = Timerobj timerid = SetTimer(0, 0, 1, AddressOf TimerProc) End Sub Public Sub TimerProc(ByVal hwnd As Long, ByVal umsg As Long, _ ByVal idEvent As Long, ByVal dwtime As Long) Dim counter As Long Dim theanswer As Double KillTimer 0, timerid 'Stop the timer For counter = 1 To 15000000 'Do some work here theanswer = theanswer + counter Next counter thetimer.Notifyme (theanswer) 'Work is done. Pass the result End Sub 'as a parameter. Client Application ------------------ The client application is a Standard .exe file consisting of one class module (clsNotify) and one form. The form has a Listbox control (lstTimes) and a CommandButton (cmdStart). Make sure you add a reference to your server application in your client project: Class Module code: Public WithEvents obj As clsTimer Private Sub Class_Terminate() Set obj = Nothing End Sub Private Sub obj_Notify(ByVal somenum As Double) Form1.lstTimes.AddItem somenum obj.StopTimer Set obj = Nothing 'Shut down the server when it has completed End Sub 'the task. Public Sub startit() Set obj = New clsTimer obj.StartTimer End Sub Form Code: Dim notifyobject As clsNotify Private Sub cmdStart_Click() notifyobject.startit End Sub Private Sub Form_Load() Set notifyobject = New clsNotify End Sub ====================================================================== Keywords : vb5all VBKBAX VBKBComp VBKBCtrl Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbbug ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1997.