Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 1st, 2007, 05:54 PM
Authorized User
 
Join Date: Apr 2007
Location: , , .
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.


Reply With Quote
  #2 (permalink)  
Old August 2nd, 2007, 06:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
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

Reply With Quote
  #3 (permalink)  
Old August 2nd, 2007, 04:05 PM
Authorized User
 
Join Date: Apr 2007
Location: , , .
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.



Reply With Quote
  #4 (permalink)  
Old August 2nd, 2007, 06:36 PM
Authorized User
 
Join Date: Apr 2007
Location: , , .
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.

Reply With Quote
  #5 (permalink)  
Old August 4th, 2007, 01:54 AM
Authorized User
 
Join Date: Apr 2007
Location: Silvassa, Dadra & Nagar Haveli, India.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.