|
Hi,
I'm designing a form without a title form. To move the form around, I have to write another simple mouse_move event that will get the location of the mouse pointer and will replace the location of the form. It works, but the thing is, when i tried to move the form around, it flickers. I tried to use the doublebuffering style, but it still flickers. Anyone know why this is or how to handle this kind of situation? Also, the mouse pointer is off by a noticable distance from the form.
Anyone, please help. I am a newbie here, so please show me your guidance.
Thank you
|
|
|
|
|
We can better help you if you post your MouseMove event code.
|
|
|
|
|
woops sorry
Here's my code
dim MDown as boolean = False
Private Sub FormaName_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If MDown Then
Me.Location = Control.MousePosition
End If
End Sub
Private Sub FormName_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Left Then
MDown = False
End If
End Sub
Private Sub FormName_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
MDown = True
End If
End Sub
With This code, I have problems with the flickering and the pointer of and also with the pointer. Try it and you'll know what i mean, I'm not good at explaining :P
Thank you
-- modified at 11:54 Wednesday 16th November, 2005
|
|
|
|
|
I tried your code and didn't see any flickering. But I did see problems with the form dragging code. Try this.
Private m_isMouseDown As Boolean = False<br />
Private m_lastMousePosition As System.Drawing.Point<br />
<br />
Private Sub FormName_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown<br />
If (e.Button = MouseButtons.Left) Then<br />
m_isMouseDown = True<br />
m_lastMousePosition = Me.MousePosition<br />
End If<br />
End Sub<br />
<br />
Private Sub FormName_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp<br />
If (e.Button = MouseButtons.Left) Then<br />
m_isMouseDown = False<br />
End If<br />
End Sub<br />
<br />
Private Sub FormName_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove<br />
Dim formPosition As System.Drawing.Point<br />
<br />
If (m_isMouseDown) Then<br />
formPosition = Me.Location<br />
formPosition.Offset(Me.MousePosition.X - m_lastMousePosition.X, _<br />
Me.MousePosition.Y - m_lastMousePosition.Y)<br />
m_lastMousePosition = Me.MousePosition<br />
Me.Location = formPosition<br />
End If<br />
End Sub
|
|
|
|
|
It's Workingg Thanks a lot
For the flickering problem, i think it appears because i was using it as an mdiChild of another form. Also, I have so many controls on the form. Coz when i tried that code with a single form, it works just fine. Any idea how to handle this problem?
|
|
|
|
|
Hmmm... I still can't reproduce this flicker issue, even in an MDI app. Perhaps my PC and video card is too good?
Does it flicker when your child forms have borders too?
|
|
|
|
|
OO, I know why. Try create an image for your background and use it as backgroundimage For your MDIContainer, you'll get the flickering effect
|
|
|
|
|
Okay. Now I'm seeing something.
I can seeing a painting issue while I'm dragging the child window.
Try this. Put the following code at the bottom of your MDI child form's constructor (the Sub New method).
Me.SetStyle(ControlStyles.DoubleBuffer, True)<br />
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
|
|
|
|
|
Hi,
I already have that in there but it's still doing it. Is it because the background image keeps painting everytime we drag the child window? Is that what is happening? If it is, is there a way to stop the background image to stop refreshing?
|
|
|
|
|
(Sorry about the late response. I was having Internet connection issues.)
As you drag the child window, the main window's background is going to need to redraw it's background. Otherwise you're going be leaving images of your child window behind as you drag it.
Applying double buffering seemed to improve the draw time significantly for me.
You may also want to try using a smaller background image. Smaller in dimension and color depth that is. This will improve the draw time. The image will tile automatically too if that'll work for you.
Also, a faster CPU and video card should improve the draw time as well.
If it still doesn't render fast enough, then you might have to consider dropping the background image.
|
|
|
|
|
It's ok.
I tried your suggestion, but it still flickers. I tried to run it without the background image. It works fine, but when i have 2 forms, and if they intersect each other, it will flicker again. I know this was becoz of the redrawing thing that each control does everytime it's modified, but I can't figure out how to make them stoppp ARgGhh. There has to be some way to handle this problem, coz when i see the MS Excel or MS Access, they have a similar layout as mine, but they don't flicker -_-
Any other ideas?
|
|
|
|
|
Regarding the flicker problem...
Can you tell me what kind of controls are on your child forms?
Are you catching the form's Move event?
Do you know if any of your controls are catching the form's Move event? (Wouldn't make sense, but doesn't hurt to ask.)
|
|
|
|
|
I have a lot of Panel :P Does that matter?
I am trying to change the control. I'm designing a new form that looks similar without so many panels. Is it going to help?
|
|
|
|
|
I doubt the Panels are the cause of the flicker.
I can't seem to reproduce this flicker issue and am therefore at a loss at what's causing it.
However, after doing an Internet search, I did find some references to MDI child window flicker issues like the one you are having. It sounds like the MDI container unnecessarily forces a WM_PAINT message on its children. Perhaps this search result can help you better than I.
http://www.google.com/search?hl=en&q=vb.net+mdi+flicker[^]
|
|
|
|
|
In Win 2000 Pro , i want permit one user have right "read only " all file in one folder , i can not do it , can you tell me .
And when i make a new group ,why Window do not permit me add any right for that group ?
|
|
|
|
|
I am attempting to edit an image to give it a non 3D effect. My problem is that the code does exactly what it is suppose to do . Because of this, quite a few images have these big ugly streaks which completely mess up the affect, all because this green in a range of 5 was to close to this color of black. (Example: try this on C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg). Does anyone have any alternative ideas of how to get a smooth image from this?
'Create a cartoonish like affect <br />
Public Function Cartoon(ByVal EditImage As Image, ByVal Range As Integer) As Image<br />
Dim ModBMP As New Bitmap(EditImage) 'Image to eidt<br />
Dim X As Integer, Y As Integer 'Positioning coordinates<br />
Dim ColorCapture As RGB 'Public Structure(3 integers to handle colors, nothing special)<br />
Dim Match As Boolean<br />
Dim R As Integer, G As Integer, B As Integer<br />
'Filter through<br />
For X = 1 To ModBMP.Width - 1<br />
For Y = 1 To ModBMP.Height - 1<br />
'Get color value of first position<br />
R = ModBMP.GetPixel(X, Y).R : G = ModBMP.GetPixel(X, Y).G : B = ModBMP.GetPixel(X, Y).B<br />
'Get color value of one pixel behind<br />
Try<br />
ColorCapture.R = ModBMP.GetPixel(X - 1, Y).R : ColorCapture.G = ModBMP.GetPixel(X - 1, Y).G : ColorCapture.B = ModBMP.GetPixel(X - 1, Y).B<br />
Catch ex As Exception<br />
'MsgBox(ex.Message)<br />
End Try<br />
'Modify to enhance check (crap code)<br />
'Dim Vivi As Integer = 0<br />
'Vivi = HighestColor(R, G, B)<br />
'If Vivi = 1 Then R = R * 5<br />
'If Vivi = 2 Then G = G * 5<br />
'If Vivi = 3 Then B = B * 5<br />
'Check Relations between two areas (ReAdjusted to hard way of adding booleans)<br />
Match = InRange(R, Range, ColorCapture.R) + InRange(G, Range, ColorCapture.G) + InRange(B, Range, ColorCapture.B)<br />
If Match = True Then R = ColorCapture.R : G = ColorCapture.G : B = ColorCapture.B<br />
'Adjust the image<br />
ModBMP.SetPixel(X, Y, Color.FromArgb(R, G, B))<br />
Next Y<br />
Next X<br />
EditImage = ModBMP<br />
Return EditImage<br />
End Function<br />
<br />
'Purpose: Check highest color value to help figure between small differences<br />
Public Function HighestColor(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Integer<br />
'Check<br />
Dim eR As Boolean, eG As Boolean, eB As Boolean<br />
'Evaluate<br />
If R < B And R < G Then eR = False<br />
If G < R And G < B Then eG = False<br />
If B < R And B < G Then eB = False<br />
If eR = True Then Return 1<br />
If eG = True Then Return 2<br />
If eB = True Then Return 3<br />
End Function<br />
<br />
'Purpose: Return boolean of whether in range of this number<br />
Public Function InRange(ByVal Number As Double, ByVal Range As Double, ByVal Target As Double) As Boolean<br />
'Check<br />
If Target <= Number + Range And Target >= Number - Range Then<br />
InRange = True<br />
Else<br />
InRange = False<br />
End If<br />
'Return Results<br />
Return InRange<br />
End Function
|
|
|
|
|
You should read my image editing articles in C#. GetPixel/SetPixel is too slow. Can you do unsafe code in VB.NET ?
Is this a smoothing filter ? There's a smoothing filter in my C# articles/library.
Also, when you change a bitmap, you should call Dispose on the old one before getting rid of it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have been looking over your articles on image editing in c#. They offer many ideas and will be helpful for some over things I plan down the road. I am not sure of how to do unsafe coding in vb.net, but I will do some research on that.
No, this is not meant to be a smoothing filter in its idea... Lets say we have a picture of a flower, purple, light shining on one side, and there is a nice clear blue sky behind it. If it was a real picture, most of the pixels would be different, like the sky might have two blue pixels right next to each other of different values that are very close. My plan is to make it so they match, but not for a smooth affect. If all the sky becomes one shade of blue, each and every piece, and the flower becomes 2 different colors, it loses it real affect. It then becomes like an odd cartoon image, which is the affect I am aiming for.
I'll modify my code for the disposal. Thank you for your advice.
|
|
|
|
|
Helloo
Any of you guys know how to stretch backgroundImage in VB.net?
I'm trying to make a program as an MDIContainer and i have created a jpg picture as the BackGroundImage. However, when I tried to resize the form, the backgroundImage will be tiled, instead of stretched. Is there a way to stretch the Image?
Thank you
|
|
|
|
|
Yes, you can set the properties to stretch the image, I believe. Or you can draw it yourself, in which case you can draw it to the size of the window.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you
I modified the form_resize so that it will create a new bitmap with a new size everytime the form resizes, it's working now.
Thank you so much
-- modified at 22:08 Tuesday 15th November, 2005
|
|
|
|
|
I have a third-party DLL that I am importing into vb.net code that renders to a device context.
<psuedo>
Render(HDC, x, y, width, height, scale, rotation_angle)
</psuedo>
I like being able to use the matrix transformations of GDI+. This makes rotation and zooming and inheriting rotation and zooming easy.
However, if I use the graphics object of my drawing surface to change the transformation matrix, then pass the device context to the render function, the rotation does not take effect for the render function. I assume this is because the render function uses GDI and does not enter the GDI+ rendering pipeline.
I have tried drawing to a bitmap, then rendering the bitmap to my drawing surface, but at a significant reduction in quality.
Does any one have any ideas on how to improve on my work, or am I fighting a losing battle?
Kevin
|
|
|
|
|
I have an Access dB with a VB.net front-end that I can display, browse, and edit records in. This program can also search through the dB to find specific records. My search criteria is set to last name and the problem I am running into is...if I have three people with the same name listed in the dB and I do a search, all three names will show up as being records in the dB (which is correct so far). But when I click on one of the search results, they all go to the same record. What would be causing this? I have stepped through my code and it seems either the identifying part (PK) of the record is missing or just not being utilized by my code properly. Has anyone had this problem before? I am kind of looking for some guidance on this solution as I am out of answers. Thank you.
Jason
I'd rather have a bottle in front of me than a frontal lobotomy.
|
|
|
|
|
can you share a snippet, just to give us a good idea about your problem.
thanks!
Marvin N. Guerrero
- Taje Kage_bunshinNunJutsU
|
|
|
|
|
Here is the code for the btnSearch_Click event and then for the lstResults_SelectedIndexChanged event. I believe it is something w/in these sections. My opinion on the problem is that I am using a string in the lstResults_SelectedIndexChanged event and there is nothing to tie the search results with the actual records (unique ID). I don't know if I am wording this right but I somehow need to tie my search results into a unique ID (Primary Key of dB). Anyway, here is the code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
'search the dataset for the record
Dim TotalRows As Integer
TotalRows = dsCards.Tables("Football Cards").Rows.Count
'if they have no active DataSet, refuse:
If dsCards.Tables.Count = 0 Then
MsgBox("please use the File menu to open a Dataset, or create a new one first.")
Exit Sub
End If
'search for the target, then display it
Dim searchfor As String = InputBox("Enter Your Search Term", "Search")
If searchfor.Length = 0 Then
Return
End If
lstResults.Items.Clear()
Dim i, x, count As Integer
For i = 0 To TotalRows - 1
x = dsCards.Tables("Football Cards").Rows(i).Item(8).ToString.ToUpper.IndexOf(searchfor.ToUpper) ' see if title column matches
If x <> -1 Then 'match
lstResults.Items.Add(dsCards.Tables("Football Cards").Rows(i).Item(8))
'add title field to listbox
count += 1
End If
Next i
If count = 0 Then 'no matches found
MsgBox("No match for " & searchfor & " was found...")
Else
lstResults.Visible = True
End If
End Sub
Private Sub lstResults_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstResults.SelectedIndexChanged
'go to the selected record
Dim dr As DataRow, dt As DataTable
lstResults.Visible = False
Dim i As Integer = 0
Dim s As String
dt = dsCards.Tables("Football Cards")
s = lstResults.SelectedItem.ToString 'which item did they click?
'find their choice
For Each dr In dt.Rows 'search the dataset to find the correct Description
dr = dsCards.Tables("Football Cards").Rows(i)
i = i + 1
If dr(8).ToString = s Then
bmCards.Position = i - 1
Exit For
End If
Next
End Sub
Thank you!
jason
I'd rather have a bottle in front of me than a frontal lobotomy.
|
|
|
|
|