Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 problems

Status
Not open for further replies.

BigInch

Petroleum
Jun 21, 2006
15,161
Using XL 2007

1) Working with a user form. The form's name is UserForm1. When I double click on the form while writing code for the form's events, the window opens with the event titled "UserForm_Click", but the form's name is actually "UserForm1". Should it not open with the title, "UserForm1_Click". Why would it be doing that? Also, when testing, an error of some kind sometimes causes XL to crash.

2) I am changing the form's pixel colors to colors stored in an RGB byte array "P"
DrawDC = DrawDibOpen()
DrawDibDraw DrawDC, Hdc, 1, 1, -1, -1, BInfo, P(1, 1), _
0, 0, BInfo.biWidth, BInfo.biHeight, 0
DrawDibClose DrawDC

That works fine (even though Hdc is DC of the handle to UserForm1), but if the form is covered by another program's window and then uncovered, the form does not automatically repaint. All previously colored areas that were covered are white when the covering program's window is moved away. Are the two problems related? I've seen some questions and solutions about forcing a repaint by including a DoEvents in a loop, but that was in regard to a progress bar that has a loop running. How can I force a repaint event without resorting to using some kind of timer control?




Independent events are seldomly independent.
 
Replies continue below

Recommended for you

Maybe the form thinks its colors should still be the background color.

Any better ideas on how to color a form in XL. Maybe write the bmp as a file, then load the file to an image!

Independent events are seldomly independent.
 
BigInch,
The answer to your first question is that the code is not within a module of the project, but within the userform itself. It does need to call Userform1_Click because the userform is itself the only user form.

For the second question, Please put the entire code so that I could more easily troubleshoot your problem.
~chemebabak
 
Thank you chemebabak.
Let me think about that.

I hate Windowz 8!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor