Sign in to follow this  
Followers 0
Damein

Gui doing something weird!

2 posts in this topic

Alright, I've been getting frustrated with this for an hour or so now.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
 
Global $YAlignment = 40
Global $hGUI
Global $hGraphic
Global $hPen
 
 
Global $NewItemLabel, $NewCost, $TotalWeeklyCost, $VarianceFromLastWeek, $SaveBudgetButton, $IniFile, $IniFileInfo, $LastWeeksBudgetTab, $CurrentWeeksBudgetTab
Global $PreviousBudgetInfoLocation[40], $PreviousBudgetInfoSpentAmount[40]
Global $PreviousBudgetTotal, $CurrentBudgetInfoLocation[40], $CurrentBudgetInfoSpentAmount[40], $CurrentBudgetTotal, $VarianceBudgetTotal
 
Opt("GUIOnEventMode", 1)
;~ $IniFile = "Budget.ini"
 
 
;~ $IniFileInfo = IniReadSection($IniFile, "PreviousBudget")
;~ If @error Then
;~  IniWrite($IniFile, "PreviousBudget", "", "")
;~ Else
;~  For $i = 1 To $IniFileInfo[0][0]
;~  $PreviousBudgetInfoLocation[$i] = $IniFileInfo[$i][0]
;~  $PreviousBudgetInfoSpentAmount[$i] = $IniFileInfo[$i][1]
;~  $PreviousBudgetTotal += $IniFileInfo[$i][1]
;~ Next
;~ EndIf
 
;~ $IniFileInfo2 = IniReadSection($IniFile, "CurrentBudget")
;~ If @error Then
;~  IniWrite($IniFile, "CurrentBudget", "", "")
;~ Else
;~  For $i = 1 To $IniFileInfo2[0][0]
;~  $CurrentBudgetInfoLocation[$i] = $IniFileInfo2[$i][0]
;~  $CurrentBudgetInfoSpentAmount[$i] = $IniFileInfo2[$i][1]
;~  $CurrentBudgetTotal += $IniFileInfo2[$i][1]
;~  $VarianceBudgetTotal = $PreviousBudgetTotal - $CurrentBudgetTotal
;~ Next
;~ EndIf
 
Global $hGUI = GUICreate("Budgetting System", 800, 700)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGui)
GUISetState()
_GDIPlus_Startup ()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
Global $hPen = _GDIPlus_PenCreate ()
    $BudgetTabs = GUICtrlCreateTab(10, 5, 780, 680)
For $i = 1 To 21
_GDIPlus_GraphicsDrawLine ($hGraphic, 342, $YAlignment+8, 380, $YAlignment+8, $hPen)
$YAlignment += 30
Next
_GDIPlus_GraphicsDrawLine ($hGraphic, 380, 49, 380, $YAlignment-22, $hPen)
_GDIPlus_GraphicsDrawLine ($hGraphic, 380, 318, 400, 318, $hPen)
    $LastWeeksBudgetTab = GUICtrlCreateTabItem("Previous Week")
For $i = 1 To 21
GUICtrlCreateLabel("Purchased At:", 20, $i * 30 + 10, 80, 30)
GUICtrlCreateInput("1", 90, $i * 30 + 8, 100, 24)
;~  GuiCtrlSetData(-1, $PreviousBudgetInfoLocation[$i])
GuiCtrlCreateLabel("Cost:", 210, $i * 30 + 10, 80,30)
GuiCtrlCreateInput("1", 240, $i * 30 + 8,100,24)
;~  GuiCtrlSetData(-1, $PreviousBudgetInfoSpentAmount[$i])
Next
GuiCtrlCreateLabel("Total:", 402,312, 120,30)
GuiCtrlCreateInput("1", 435, 308,100,24)
;~  GuiCtrlSetData(-1, $PreviousBudgetTotal)
 
$CurrentWeeksBudgetTab = GUICtrlCreateTabItem("Current Week")
$YAlignment = 40
For $i = 1 To 21
    GUICtrlCreateLabel("Purchased At:", 20, $i * 30 + 10, 80, 30)
    GUICtrlCreateInput("2", 90, $i * 30 + 8, 100, 24)
;~  GuiCtrlSetData(-1, $CurrentBudgetInfoLocation[$i])
GuiCtrlCreateLabel("Cost:", 210, $i * 30 + 10, 80,30)
GuiCtrlCreateInput("2", 240, $i * 30 + 8,100,24)
;~  GuiCtrlSetData(-1, $CurrentBudgetInfoSpentAmount[$i])
Next
GuiCtrlCreateLabel("Total:", 402,312, 120,30)
GuiCtrlCreateInput("2", 435, 308,100,24)
;~  GuiCtrlSetData(-1, $CurrentBudgetTotal)
GuiCtrlCreateLabel("Variance:", 550,312, 120,30)
GuiCtrlCreateInput("2", 600, 308,100,24)
;~  GuiCtrlSetData(-1, $VarianceBudgetTotal)
 
;~  $EditTab = GUICtrlCreateTabItem("Add to budget")
;~  GuiCtrlCreateButton("Test", 300,300)
 
;~  GUICtrlCreateTabItem("")
 
 
 
 
While 1
    Sleep(10)
WEnd
 
Func _Exit()
_GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()
    Exit
EndFunc

In this script I have commented some things out that does not need to be shown unless you have the .ini. So, I replaced with 1's and 2's to show the difference in tabs.

Now currently all is okay, except I want to add another tab.

(Side note, until I switch to Current and then back to previous I can't see the labels/boxes for Previous. Any ideas why?)

Now in this script, I added the new tab, and all my GDI lines disappear!

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
 
Global $YAlignment = 40
Global $hGUI
Global $hGraphic
Global $hPen
 
 
Global $NewItemLabel, $NewCost, $TotalWeeklyCost, $VarianceFromLastWeek, $SaveBudgetButton, $IniFile, $IniFileInfo, $LastWeeksBudgetTab, $CurrentWeeksBudgetTab
Global $PreviousBudgetInfoLocation[40], $PreviousBudgetInfoSpentAmount[40]
Global $PreviousBudgetTotal, $CurrentBudgetInfoLocation[40], $CurrentBudgetInfoSpentAmount[40], $CurrentBudgetTotal, $VarianceBudgetTotal
 
Opt("GUIOnEventMode", 1)
;~ $IniFile = "Budget.ini"
 
 
;~ $IniFileInfo = IniReadSection($IniFile, "PreviousBudget")
;~ If @error Then
;~  IniWrite($IniFile, "PreviousBudget", "", "")
;~ Else
;~  For $i = 1 To $IniFileInfo[0][0]
;~  $PreviousBudgetInfoLocation[$i] = $IniFileInfo[$i][0]
;~  $PreviousBudgetInfoSpentAmount[$i] = $IniFileInfo[$i][1]
;~  $PreviousBudgetTotal += $IniFileInfo[$i][1]
;~ Next
;~ EndIf
 
;~ $IniFileInfo2 = IniReadSection($IniFile, "CurrentBudget")
;~ If @error Then
;~  IniWrite($IniFile, "CurrentBudget", "", "")
;~ Else
;~  For $i = 1 To $IniFileInfo2[0][0]
;~  $CurrentBudgetInfoLocation[$i] = $IniFileInfo2[$i][0]
;~  $CurrentBudgetInfoSpentAmount[$i] = $IniFileInfo2[$i][1]
;~  $CurrentBudgetTotal += $IniFileInfo2[$i][1]
;~  $VarianceBudgetTotal = $PreviousBudgetTotal - $CurrentBudgetTotal
;~ Next
;~ EndIf
 
Global $hGUI = GUICreate("Budgetting System", 800, 700)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGui)
GUISetState()
_GDIPlus_Startup ()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
Global $hPen = _GDIPlus_PenCreate ()
    $BudgetTabs = GUICtrlCreateTab(10, 5, 780, 680)
For $i = 1 To 21
_GDIPlus_GraphicsDrawLine ($hGraphic, 342, $YAlignment+8, 380, $YAlignment+8, $hPen)
$YAlignment += 30
Next
_GDIPlus_GraphicsDrawLine ($hGraphic, 380, 49, 380, $YAlignment-22, $hPen)
_GDIPlus_GraphicsDrawLine ($hGraphic, 380, 318, 400, 318, $hPen)
    $LastWeeksBudgetTab = GUICtrlCreateTabItem("Previous Week")
For $i = 1 To 21
GUICtrlCreateLabel("Purchased At:", 20, $i * 30 + 10, 80, 30)
GUICtrlCreateInput("1", 90, $i * 30 + 8, 100, 24)
;~  GuiCtrlSetData(-1, $PreviousBudgetInfoLocation[$i])
GuiCtrlCreateLabel("Cost:", 210, $i * 30 + 10, 80,30)
GuiCtrlCreateInput("1", 240, $i * 30 + 8,100,24)
;~  GuiCtrlSetData(-1, $PreviousBudgetInfoSpentAmount[$i])
Next
GuiCtrlCreateLabel("Total:", 402,312, 120,30)
GuiCtrlCreateInput("1", 435, 308,100,24)
;~  GuiCtrlSetData(-1, $PreviousBudgetTotal)
 
$CurrentWeeksBudgetTab = GUICtrlCreateTabItem("Current Week")
$YAlignment = 40
For $i = 1 To 21
    GUICtrlCreateLabel("Purchased At:", 20, $i * 30 + 10, 80, 30)
    GUICtrlCreateInput("2", 90, $i * 30 + 8, 100, 24)
;~  GuiCtrlSetData(-1, $CurrentBudgetInfoLocation[$i])
GuiCtrlCreateLabel("Cost:", 210, $i * 30 + 10, 80,30)
GuiCtrlCreateInput("2", 240, $i * 30 + 8,100,24)
;~  GuiCtrlSetData(-1, $CurrentBudgetInfoSpentAmount[$i])
Next
GuiCtrlCreateLabel("Total:", 402,312, 120,30)
GuiCtrlCreateInput("2", 435, 308,100,24)
;~  GuiCtrlSetData(-1, $CurrentBudgetTotal)
GuiCtrlCreateLabel("Variance:", 550,312, 120,30)
GuiCtrlCreateInput("2", 600, 308,100,24)
;~  GuiCtrlSetData(-1, $VarianceBudgetTotal)
 
$EditTab = GUICtrlCreateTabItem("Add to budget")
GuiCtrlCreateButton("Test", 300,300)
 
GUICtrlCreateTabItem("")
 
 
 
 
While 1
    Sleep(10)
WEnd
 
Func _Exit()
_GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()
    Exit
EndFunc

And in this one, with the GuiCtrlCreateTabItem("") removed most of my GDI lines stay, but on all tabs, including the third one.

I can't seem to get it right, any help would be appreciated.


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I already told you a method to do this, but you dont answer me yet. you only need to addapt it to your script. If you have problems with that just ask for help, but dont ignore my answer because i spent time doing that.

EDIT: The reason why your lines are being erased is because the window is being refreshed and you are not doing anything to prevent that situation. usually you should put the draw in a PicControl like my example shows you, or hooking the WM_PAINT of your GUI to repaint your drawing every time that the entire GUI is repainted.

Edited by monoscout999

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0