Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2007, 05:54 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form and Combo Box Leave Trails on Screen

I am working with a form which has a combo box drop down list and am getting visual trails on the screen (similar to when mouse settings are set to trails ON)


If I click and drag the entire form around it leaves trails.
If I select from the combo box it leaves a visual of the list in the background after it colapses.


I don't know if it is the way or mode I have the form open in or something else.

Has anyone ever seen this before? Any help is appreciated.

Thanks,
Coby.


 
Old August 2nd, 2007, 06:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Do you have ScreenUpdating set to false? This will often cause the behaviour you've described for dragging the form around.

Alternatively it could just be that you computer is trying to process more things at that point than its happy with and it doesn't quite get the screen refesh right. If this is the case you could try using

Code:
 Application.DoEvents
or alternatively you could bring the full wrath of the Windows operating system (WinAPI) to bear on the matter by using:

Code:
 
Declare Function FindWindow _
    Lib "user32" _
    Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) _
    As Long

Declare Function FindWindowEx _
    Lib "user32" _
    Alias "FindWindowExA" ( _
    ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, _
    ByVal lpsz2 As String) _
    As Long

Declare Function InvalidateRect _
    Lib "user32" ( _
    ByVal hWnd As Long, _
    lpRect As Long, _
    ByVal bErase As Long) _
    As Long

Declare Function UpdateWindow _
    Lib "user32" ( _
    ByVal hWnd As Long) _
    As Long

Sub RepaintActiveWindow()

Dim hWnd As Long
Dim strExcel As String

    strExcel = "EXCEL" & Format(Application.Version, "#0")

    Application.ScreenUpdating = True

    ' Find Excel
    hWnd = FindWindow("XLMAIN", Application.Caption)

    ' Find the active window in Excel
    hWnd = FindWindowEx(hWnd, 0, strExcel, ActiveWindow.Caption)

    ' Mark the client area 'dirty'
    InvalidateRect hWnd, 0&, True

    ' Force a redraw
    UpdateWindow hWnd

End Sub
Of course both of the above solutions require you to determine a point in your code to do a refresh.

Maccas

 
Old August 2nd, 2007, 04:05 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes! I do have the screen updating = False. So, I will try setting it to true and see how it works out.

Thanks!!!

Coby.



 
Old August 2nd, 2007, 06:36 PM
Authorized User
 
Join Date: Apr 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That did it! So, I just turned it to True, Showed the form, On form close I turned it back to False and I get both effects wanted.

Perfect.
I appreciate your help greatly.

Coby.

 
Old August 4th, 2007, 01:54 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I need your help in using comboboxes. I want to use 2 comboboxes, one for item name and the other for suppliers.

The idea is that when i will select the item in first combobox, then in second combobox should get populated with the suppliers of that item only.

In accordance to the selection in second combobox, i want to change certain details in some cells using the data stored in other sheet.



Yogesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Combo Box dependent transferred to another form Ebaad Access VBA 1 May 17th, 2007 12:50 PM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.