473,568 Members | 2,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paint on lostfocus

Why when I lost focus (go to back) on form all GDI+ paints disappears.....
BUG or I do something wrong????

TNX
Nov 15 '05 #1
4 2163
OK figured what is the problem:
while lost focus on form occures event of Paint (I draw there) - Is any way
to prevent it??? or maybe other event to paint on load (_load do not work...
it's paits controls afterware...) ???
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:ud******** ******@TK2MSFTN GP10.phx.gbl...
Why when I lost focus (go to back) on form all GDI+ paints disappears.....
BUG or I do something wrong????

TNX

Nov 15 '05 #2
You are most likely painting stuff outside of OnPaint.

OnPaint needs to know how to draw everything, since the window don't
remember how it looks, it just appears to, until something covers part of
it or all.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #3
I'm sorry, I'm a little confused. What are you trying to do?
When focus is given, the paint event is thrown to notify your program that
it needs to redraw it's own window.
You don't want to prevent the OnPaint event.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #4

Hi Tamir,

I do not think you want to prevent the paint event to happen.
The paint event occurs whenever some area of your form is invalid. If you
stopped paint event, the invalid area will not draw back, while it may
remain its being overlapped graphic.(For example, when you place a window
over your form, then move the window away, your form will not repaint, so
it being overlapped area will still remain the winodw's graphic. )

The right solution is store your paint DC and whenever the paint event
happens, redraw your invalid area. But most of these things have been done
by the windows, so you only need to focurs some few things. For example, if
you update some UI elements of WinForm, most of the time .Net Framework
will invoke the paint event(through invoke Invalidate method to achieve
this) for you, but some times, you need to explicit invoke the Invalidate
method to notify your form to repaint.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8930
by: MJW | last post by:
Is there a way for me to know if or which command button was just clicked that triggers the LostFocus event for the current control on a Form? I have a form that has many types of users who each have their own set of fields they can change. Therefore I use setfocus property in the lostfocus event for some of the users to get from one...
0
1887
by: Duncan Mole | last post by:
Hi, I have created a control which draws a title bar and provides a drop down menu for a Smart Device Application. It seemed to work fine until I came to add an event handler to act on Paint messages in the form which has drawn the control. Evidently, the control is consuming all of these messages. How can I pass them back/on? I have a...
2
21218
by: vooose | last post by:
Does anyone know the difference between these two? The doc for LostFocus says 'Occurs when the control loses focus.' whereas for Leave it says 'Occurs when the input focus leaves the control' The doc also states that for controls losing focus you should use Leave, so I do. Another reason I used it is because comboBox.LostFocus event
4
10420
by: dudzcom | last post by:
hi, this is the first time i've posted to this board, though i have been a devoted lurker for some time i have been working in vb.net and run into a couple problems that seem to require solutions involving what was in previous versions of vb, refered to as gotfocus/lostfocus events. however, it seems that though people online refer to them, my...
4
21146
by: Bernard Bourée | last post by:
I have some TextBoxes created by code. I want to write a procedure to handle the lost of focus of any of these TextBox. How should I do that ? Thanks --
4
1378
by: Wayne Wengert | last post by:
I have a form that has a cbo set to TabIndex 0 (it is the only item set to tabindex 0). On page Load if I step through the code that cbo LostFocus event fires after other initializations are completed and after the LostFocus event completes, that cbo gets focus and the form opens? Why is that LostFocus event firing? Any hints on how to debug...
6
3775
by: Carmon | last post by:
I am using Managed C++ with a CFormView and a MaskedTextBox and have used MAKE_DELEGATE to sink the LostFocus event of this control. I have other events I've sinked off this control and they all work fine, however, the LostFocus does not fire. I found Scribble online and they do the same thing I did, however, when I used this code in...
14
14585
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user presses the "Save" button while the textbox has the focus, the LostFocus code doesn't run at the right time, so that the "Save" function is dealing with...
2
8053
by: Jason Huang | last post by:
Hi, In my .Net 1.1 C# windows form Form1 I have nothing but 2 TextBox controls on the Form1, the T1 and T2. I would like to test the sequence of the GotFocus LostFocus things, so I have the following code on the Form1. this.T1.LostFocus +=new EventHandler(T1_LostFocus); this.T1 .GotFocus +=new EventHandler(T1_GotFocus); this.T2...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.