HelpVB Menu Flickering

Posts 1–9 of 9 · Page 1 of 1
VB Menu Flickering
I have a DrawString menu i had made awhile back..

It flickers like crap and i dont know how to fix it, i have already tried to turn dubblebuffered on.

Thanks

SS of Menu, I cant take a screenshot of it flickering...



simple DrawString using FindWindow
You're drawing it with VB GDI+?
Quote Originally Posted by Biesi View Post
You're drawing it with VB GDI+?
yes, how else would i draw it?

edit : It also works in game, but when i take a screenshot it doesn't show the menu too and it also flickers like crap....
Quote Originally Posted by lucasheer715 View Post
yes, how else would i draw it?

edit : It also works in game, but when i take a screenshot it doesn't show the menu too and it also flickers like crap....
Somethin about your Refreshing method i guess...
Which way do you use to draw the menu ?
okey ..
i tried to do something like that with c++.
i tried to put this->TopLevel= True , it Flicker for a while ....
Cf window is getting top level all the time , cuz of that , any menu get dissapeared unless it is D3D
sry4 bad english
i hope u get it
(he asked me on skype)
Crossfire Menu VB Flickers - Pastebin.com

Timer
Code:
    Private Sub DrawMenu_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrawMenu.Tick
        update_menu()
    End Sub
update_menu
Code:
 Private Sub update_menu()
        Dim TargetProcess As Process() = Process.GetProcessesByName("Crossfire")
        If TargetProcess.Length = 1 Then
        Else
            DrawMenuBorder(10, 10, Pens.Red, MenuWidth, MenuHeight)
            DrawTitle(10, 10, "LucasHeer715 Menu V1.0", Brushes.Red, 25)
            MenuItemSpaces += 40
            DrawString(10, MenuItemSpaces, Item1.Split(";")(0), brushcoloritem1, 15)
            DrawString(320, MenuItemSpaces, Item1.Split(";")(1), brushcoloritem1, 15)
            MenuItemSpaces += 20
            DrawString(10, MenuItemSpaces, Item2.Split(";")(0), brushcoloritem2, 15)
            DrawString(320, MenuItemSpaces, Item2.Split(";")(1), brushcoloritem2, 15)
            MenuItemSpaces += 20
            DrawString(10, MenuItemSpaces, Item3.Split(";")(0), brushcoloritem3, 15)
            DrawString(320, MenuItemSpaces, Item3.Split(";")(1), brushcoloritem3, 15)
            MenuItemSpaces += 20
            DrawString(10, MenuItemSpaces, Item4.Split(";")(0), brushcoloritem4, 15)
            DrawString(320, MenuItemSpaces, Item4.Split(";")(1), brushcoloritem4, 15)
            MenuItemSpaces = 5
        End If
    End Sub
DrawString
Code:
    Private Sub DrawString(ByVal X As Integer, ByVal Y As Integer, ByVal TextI As String, ByVal brush As Brush, ByVal fontsize As Integer)
        Dim Crossfire As Graphics = Graphics.FromHwnd(New IntPtr(FindWindow("CrossFire", "CrossFire")))
        Dim MenuItem As Font
        MenuItem = New System.Drawing.Font("Times", fontsize, FontStyle.Regular)
        Crossfire.DrawString(TextI, MenuItem, brush, X, Y)
        SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
        DoubleBuffered = True
        Crossfire.Dispose()
    End Sub
So 1 call to "update_menu()" leads to... 10+ calls to FindWindow() and 10+ new Drawing.Font objects.


That's going to be slow..

List I said last night, store a copy of the hWnd locally and stop calling FindWindow() so damn much. Change code and update post : )

 
cs

Quote Originally Posted by lucasheer715 View Post
yes, how else would i draw it?
...
With crayons?

Post code from now on and we won't have to ask [strike]stupid[/strike] these types of questions.
Quote Originally Posted by abuckau907 View Post
(he asked me on skype)
Crossfire Menu VB Flickers - Pastebin.comⓘ

Timer
Code:
    Private Sub DrawMenu_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrawMenu.Tick
        update_menu()
    End Sub
update_menu
Code:
 Private Sub update_menu()
        Dim TargetProcess As Process() = Process.GetProcessesByName("Crossfire")
        If TargetProcess.Length = 1 Then
        Else
            DrawMenuBorder(10, 10, Pens.Red, MenuWidth, MenuHeight)
            DrawTitle(10, 10, "LucasHeer715 Menu V1.0", Brushes.Red, 25)
            MenuItemSpaces += 40
            DrawString(10, MenuItemSpaces, Item1.Split(";")(0), brushcoloritem1, 15)
            DrawString(320, MenuItemSpaces, Item1.Split(";")(1), brushcoloritem1, 15)
            MenuItemSpaces += 20
            DrawString(10, MenuItemSpaces, Item2.Split(";")(0), brushcoloritem2, 15)
            DrawString(320, MenuItemSpaces, Item2.Split(";")(1), brushcoloritem2, 15)
            MenuItemSpaces += 20
            DrawString(10, MenuItemSpaces, Item3.Split(";")(0), brushcoloritem3, 15)
            DrawString(320, MenuItemSpaces, Item3.Split(";")(1), brushcoloritem3, 15)
            MenuItemSpaces += 20
            DrawString(10, MenuItemSpaces, Item4.Split(";")(0), brushcoloritem4, 15)
            DrawString(320, MenuItemSpaces, Item4.Split(";")(1), brushcoloritem4, 15)
            MenuItemSpaces = 5
        End If
    End Sub
DrawString
Code:
    Private Sub DrawString(ByVal X As Integer, ByVal Y As Integer, ByVal TextI As String, ByVal brush As Brush, ByVal fontsize As Integer)
        Dim Crossfire As Graphics = Graphics.FromHwnd(New IntPtr(FindWindow("CrossFire", "CrossFire")))
        Dim MenuItem As Font
        MenuItem = New System.Drawing.Font("Times", fontsize, FontStyle.Regular)
        Crossfire.DrawString(TextI, MenuItem, brush, X, Y)
        SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
        DoubleBuffered = True
        Crossfire.Dispose()
    End Sub
So 1 call to "update_menu()" leads to... 10+ calls to FindWindow() and 10+ new Drawing.Font objects.


That's going to be slow..

List I said last night, store a copy of the hWnd locally and stop calling FindWindow() so damn much. Change code and update post : )

 
cs


With crayons?

Post code from now on and we won't have to ask [strike]stupid[/strike] these types of questions.
Shut up, I figure if anyone can help me then they probably know what
simple DrawString using FindWindow
means... You act like i am retarded... I can already make one in c++ but figure it wouldn't flicker if i just translated to Visual Basic... Everyone who hacks crossfire knows what a DrawString or DrawFont menu is cause it decreases FPS a'lot... You don't even play Crossfire
I don't want to argue (erm..get in trouble for arguing*). Post code when you get around to actually changing it. Maybe let us know if any performance is gained? Or not.

edit: Exactly *****, we don't even play and were trying to help you..
How did you get past xtrap with vb? im making a blackmarket recording program in vb and i cant get it to get past xtrap....also how did you get the form to work in game? i tried unfocus but that makes crossfire stop responding...(maybe because i still have vb opened....) pm me some codes please...
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us