Jump to content
Sign in to follow this  
parazitenew

[Resolved] GUICtrlOnHover and WM_COMMAND

Recommended Posts

parazitenew

Hello, excuse my english I'll do my best :D

I used the UDF GUICtrlOnHover v2.1 and I loved it, so I wanted to use it again with another software, but I had a problem, the "PrimaryDown_Proc" is not working until I delete GUIRegisterMsg($WM_COMMAND, "WM_COMMAND").

The most strange in all this, that I have the same function "WM_COMMAND" in the first software and it works right.

I know that the author of this UDF said that this issues is fixed but obviously, not.

Someone who had the same problem can tell me if this can be resolved ?

Thanks.

(lot of thanks to the author of this UDF)

Edited by parazitenew

Share this post


Link to post
Share on other sites
parazitenew

any idea ?

Share this post


Link to post
Share on other sites
Melba23

parazitenew,

Firstly, welcome to the AutoIt forum. :)

Next, we discourage bumping your own topic within 24hrs - remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.

And finally, it is very difficult to make any sensible suggestions without seeing the script that you are using - so I suggest you post it so we can see where the problem might be. When you post the script please use Code tags - put [autoit] before and [/autoit] after it so you get a scrolling box and syntax colouring.

Over to you. :)

M23

P.S. Selon ton adresse mail, tu es francais - si tu ne comprends pas ce que je viens de dire, dis-le. ;)

Your email address suggests you are French - if you do not understand what I have written, ask.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
wakillon

P.S. Selon ton adresse mail, tu es français - si tu ne comprends pas ce que je viens de dire, dis-le. ;)

Est ce que cela veut dire que les français sont dur a la comprenette ? :D


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
parazitenew

Sorry for, the bump, I'm Algerian not french and I understood :D

I didn't find the "Edit" Button, so I'll put the script here.

The func of the Primary down is at line: 907

The WM_COMMAND at line: 868

The control (image) at line: 112

the dll file (the image is in, its a .ico file) : must be in Script Directory

"Link deleted"

you'll find three errors, the Email tag on the script, mut be delete.

"Script deleted"

Edited by parazitenew
Changed tags

Share this post


Link to post
Share on other sites
Melba23

parazitenew,

It is as I suspected - the UDF already registers the WM_COMMAND message so when you register it in your script, you overwrite the UDF handler. ;)

As explained in the UDF header, you need to call the UDF handler function from within your own handler:

; B) This UDF registering WM_COMMAND and WM_LBUTTONDOWN window messages.
; Please ensure that those messages are not used after including this library,
; if they do, you will have to call __GUICtrl_SOH_WM_COMMAND and GUICtrl_SOH_WM_LBUTTONDOWN
; inside those functions. Example:

Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
;    __GUICtrl_SOH_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
;     ...
EndFunc

So you need to add that line to your WM_COMMAND handler at line #845 - then your OnHover callbacks should work. All clear? :)

M23

P.S. When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
parazitenew

We were editing my pot at the same time you and me for autoit tag :D

I added the line and it works, awesome.

So, why I didn't have this probleme with the other script, I called the library on the top with others include, I called my WM_COMMAND function at the bigining just before the While boucle. Exactly like this script, and it works normally.

here is the script:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiTab.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <String.au3>
#include <File.au3>
#include <GuiEdit.au3>
#include <Word.au3>
#Include <Array.au3>
#include <StaticConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ScreenCapture.au3>
#include <ListBoxConstants.au3>
#include <GuiConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#include <GUICtrlOnHover.au3>
#include <GuiComboBoxEx.au3>
#NoTrayIcon;Vérification du fichier dll
If Not FileExists( @ScriptDir & "\wcs.dll") Then
MsgBox(16,"Error","wcs.dll is missing")
Exit
EndIf



;==============================
;Intro
;==============================
$intro = GUICreate("",587,305)
GUISetStyle($WS_BORDER)
$pic = GUICtrlCreatePic("", -1, -1,592,332)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 8, $IMAGE_BITMAP, 592, 332, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)
GUISetState(@SW_SHOW)
;Version du programme
$v1 = 1
$v2 = 0
$v3 = 0

;Vérification de la mise à jour, importation du fichier updateWCS.ini
InetGet("https://dl.dropbox.com/u/72714060/updateWCS.ini",@ScriptDir & "\updateWCS.ini")

;Lire à partir du .ini la nouvelle version
$maj1 = IniRead(@ScriptDir & "\updateWCS.ini","0","maj1","")
$maj2 = IniRead(@ScriptDir & "\updateWCS.ini","0","maj2","")
$maj3 = IniRead(@ScriptDir & "\updateWCS.ini","0","maj3","")

;Comparer la nouvelle version avec la version actuelle
If $maj1 > $v1 Then
MsgBox(64,"Update Finder"," An update is available: v " & $maj1 & "." & $maj2 & "." & $maj3 & @LF & "Go to: www.r-soft.wix.com/rsoft")
ElseIf $maj1 = $v1 Then
If $maj2 > $v2 Then
MsgBox(64,"Update Finder"," An update is available: v " & $maj1 & "." & $maj2 & "." & $maj3 & @LF & "Go to: www.r-soft.wix.com/rsoft")
ElseIf $maj2 = $v2 Then
If $maj3 > $v3 Then
MsgBox(64,"Update Finder"," An update is available: v " & $maj1 & "." & $maj2 & "." & $maj3 & @LF & "Go to: www.r-soft.wix.com/rsoft")
EndIf
EndIf
EndIf
Sleep(1000)
GUIDelete($intro)
;==============================


;==============================
;Création du GUICreate
;==============================

$gui = GUICreate("WCS 1.0 Light",900,700)
;Création BK color
$pic = GUICtrlCreatePic("", 0, 0,900,700)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 7, $IMAGE_BITMAP, 900, 700, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)
GUICtrlSetState(-1,$GUI_DISABLE)

;Création du footstep
$pic = GUICtrlCreatePic("", 0, 581,900,100)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 1, $IMAGE_BITMAP, 900, 100, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

;Création du headstep calcul des éléments du bassin
$pic = GUICtrlCreatePic("", 520, 0,370,30)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 3, $IMAGE_BITMAP, 370, 30, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

GUICtrlCreateLabel("Calculation of the characteristics of watershed",570,7,280,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)

;Création du headstep tableau
$pic = GUICtrlCreatePic("", 10, 0,500,30)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 2, $IMAGE_BITMAP, 500, 30, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

GUICtrlCreateLabel("Enter the elevations of contour lines and the partial areas corresponsantes",45,7,450,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)

;Création du menu
$fichier = GUICtrlCreateMenu("File")
$open = GUICtrlCreateMenuItem("Open project",$fichier)
$save = GUICtrlCreateMenuItem("Save project",$fichier)
$or = GUICtrlCreateMenuItem("",$fichier)
$exit = GUICtrlCreateMenuItem("Exit",$fichier)
$outils = GUICtrlCreateMenu("Tools")
$export = GUICtrlCreateMenuItem("Export to MS Word",$Outils)
$aide = GUICtrlCreateMenu("Help ?")
$help = GUICtrlCreateMenuItem("How to use the software",$aide)

;Bouton caclul tableau
$calcul_tableau = GUICtrlCreateIcon("wcs.dll",6,70,335,120,37)
_GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")

GUICtrlCreateLabel("Table calculation",88,345)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)

$additem = GUICtrlCreateIcon("wcs.dll",9,10,335,20,37)
_GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
$delitem = GUICtrlCreateIcon("wcs.dll",12,35,335,20,37)
_GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")


;Création du listview
Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0
Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)

$lv = _GUICtrlListView_Create($gui, "Elevation min|Elevation max|Area between the contour lines|% of total|% accrued|hi|di", 10, 30, 500, 300, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($lv, $LVS_EX_GRIDLINES)
_GUICtrlListView_SetBkColor($lv,0xb79876)
_GuiCtrlListView_SetColumnWidth($lv,0,80)
_GuiCtrlListView_SetColumnWidth($lv,1,80)
_GuiCtrlListView_SetColumnWidth($lv,2,90)





;Labels Résultats des calculs
$pic = GUICtrlCreatePic("", 520, 120,370,35)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 3, $IMAGE_BITMAP, 370, 35, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

$pic = GUICtrlCreatePic("", 520, 190,370,35)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 3, $IMAGE_BITMAP, 370, 35, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

$pic = GUICtrlCreatePic("", 520, 260,370,35)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 3, $IMAGE_BITMAP, 370, 35, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

;Périmètre
GUICtrlCreateLabel("Perimeter of the watershed (Km)",530,50)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$perimetre_input = GUICtrlCreateInput("",685,47,50,20)
$calcul = GUICtrlCreateIcon("wcs.dll",6,530,70,60,30)
_GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
GUICtrlCreateLabel("Calculate",540,77)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)


;Surface tableau
$somme_label_tableau = GUICtrlCreateLabel("",200,350,100,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xfff)

;Surface
$somme_label = GUICtrlCreateLabel("",530,165,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("t",564,129,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("S",550,125,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;Kc
$Kc_label = GUICtrlCreateLabel("",630,165,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("c",654,129,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("K",640,125,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;L
$L_label = GUICtrlCreateLabel("",710,165,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("p",744,129,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("L",730,125,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;TC
$Tc_label = GUICtrlCreateLabel("",820,165,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("c",834,129,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("T",820,125,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;Ip
$Ip_label = GUICtrlCreateLabel("",630,235,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("p",645,198,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("I",640,195,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;Hmoy
$Hmoy_label = GUICtrlCreateLabel("",530,235,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("moy",566,198,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("H",550,194,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;Ig
$Ig_label = GUICtrlCreateLabel("",725,235,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("g",742,202,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("I",735,198,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;Ds
$Ds_label = GUICtrlCreateLabel("",820,235,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("s",834,202,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("D",820,198,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;H médiane
$hmed_label = GUICtrlCreateLabel("",530,305,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("med",566,270,80,20)
GUICtrlSetFont(-1,10,400,1)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)
GUICtrlCreateLabel("H",550,265,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

;Dénivelé simple
$D_label = GUICtrlCreateLabel("",820,305,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,12,400,1)
GUICtrlSetColor(-1,0xfff)

GUICtrlCreateLabel("D",820,265,80,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1,14,400,1)
GUICtrlSetColor(-1,0xffffff)

GUICtrlCreateGroup("",520,380,370,190)
;Classe relief Ds
GUICtrlCreateLabel("ORSTOM classification based relief Ds",550,400)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$relief_ds_label = GUICtrlCreateLabel("",550,425,200,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xfff)

;Classe relief Ig
GUICtrlCreateLabel("ORSTOM classification based relief Ig",550,450)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$relief_ig_label = GUICtrlCreateLabel("",550,475,200,20)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xfff)
;=================================================================
;Courbe hypsométrique
;=================================================================
GUICtrlCreateGroup("",10,380,500,190)

;Tracer la courbe
$courbe = GUICtrlCreateIcon("wcs.dll",6,390,530,100,30)
_GUICtrl_OnHoverRegister(-1, "_Hover_Proc", "_Leave_Hover_Proc", "PrimaryDown_Proc", "PrimaryUp_Proc")
GUICtrlCreateLabel("Trace the graph",400,537)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0xffffff)

;Tension de courbure
GUICtrlCreateLabel("Tensility of curvature",20,410)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$T_box = GUICtrlCreateCombo("",125,410,50,20,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"0.1|0.2|0.3|0.4|0.5|0.6|0.7|0.8|0.9|1")

;Choix de la couleur
GUICtrlCreateLabel("Color of the graph",20,450)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$C_box = _GUICtrlComboBoxEx_Create($gui,"",125,450,80,100,$CBS_DROPDOWNLIST)

$hImage = _GUIImageList_Create (16, 16, 5, 3)
_GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($C_box, 0xFF0000, 16, 16))
_GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($C_box, 0x0c791e, 16, 16))
_GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($C_box, 0xFF0000ec, 16, 16))
_GUICtrlComboBoxEx_SetImageList ($C_box, $hImage)


_GUICtrlComboBoxEx_AddString ($C_box, "Red", 0, 0)
_GUICtrlComboBoxEx_AddString ($C_box, "Green", 1, 1)
_GUICtrlComboBoxEx_AddString ($C_box, "Blue", 2, 2)

;Epaisseur
GUICtrlCreateLabel("Thickness of graph",20,490)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$ep_box = GUICtrlCreateCombo("",125,490,50,20,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"1|2")


$Tableau_Dummy = GUICtrlCreateDummy()
$Calcul_Dummy = GUICtrlCreateDummy()
$Courbe_Dummy = GUICtrlCreateDummy()
$add_dummy = GUICtrlCreateDummy()
$del_dummy = GUICtrlCreateDummy()


GUISetState(@SW_SHOW)
;================================================================================
;Attente de l'utilisateur
;================================================================================

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


While 1

$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
;======================================
;Calcul du tableau
;======================================
Case $msg = $Tableau_Dummy

$nb_item = _GUICtrlListView_GetItemCount($lv);Calcul du nombre d'entrée

If $nb_item < 1 Then
MsgBox(48,"","The table is empty")
Else
Local $array [$nb_item] [7];Tableau, Nombre de ligne = nombre d'entrée + 1, 6 colonnes

;Lecture des valeurs du listview
for $i = 0 to $nb_item -1
$array [$i][0] = _GUICtrlListView_GetItemText($lv, $i)
$array [$i][1] = _GUICtrlListView_GetItemText($lv, $i, 1)
$array [$i][2] = _GUICtrlListView_GetItemText($lv, $i, 2)
Next

;Calcul de la somme des superficies partielle (Superficie totale)
$somme = 0
for $i = 0 to $nb_item -1
$somme = $somme + $array [$i][2]
Next
GUICtrlSetdata($somme_label_tableau,$somme & " Km²")

;Ecriture des superficies parielles en % sur la listview
for $i = 0 to $nb_item -1
$array [$i][3] = Round(($array [$i][2] * 100 )/ $somme,2)
_GUICtrlListView_SetItemText($lv,$i, $array [$i][3],3)
Next

;Ecriture des superficies cumulées en % sur la listview
$array [$nb_item-1][4] = $array [$nb_item -1][3]
_GUICtrlListView_SetItemText($lv,$nb_item-1, $array [$nb_item-1][4],4)
for $i = $nb_item - 2 to 0 Step -1
$array [$i][4] = $array [$i+1][4] + $array [$i][3]
_GUICtrlListView_SetItemText($lv,$i, $array [$i][4],4)
Next

;Ecriture des hi/di sur la lsitview
for $i = 0 to $nb_item -1
$array[$i][5] = ($array[$i][0]+$array[$i][1])/2
_GUICtrlListView_SetItemText($lv,$i, $array [$i][5],5)
$array[$i][6] = ($array[$i][1]-$array[$i][0])
_GUICtrlListView_SetItemText($lv,$i, $array [$i][6],6)
Next
;Somme de ai*hi
$somme_aihi = 0

for $i = 0 to $nb_item -1
$somme_aihi = $somme_aihi + ($array [$i][2]*$array [$i][5])
Next

;Calcul de hmoy
$hmoy = $somme_aihi/$somme
GUICtrlSetData($Hmoy_label, Round($hmoy,2)&" m")
EndIf


;=====================================
;Calcul des éléments du bassin versant
;=====================================
Case $msg = $Calcul_Dummy
;Le champ périmètre ne doit pas être vide
If GUICtrlRead($perimetre_input) = "" Or GUICtrlRead($Hmoy_label) = "" Then
MsgBox(48,"","Perimeter or average height unknown")
Else
;Calcul du nombre d'entrée
$nb_item = _GUICtrlListView_GetItemCount($lv)

;Tableau, Nombre de ligne = nombre d'entrée + 1, 6 colonnes
Local $array [$nb_item] [7]

;Lis les superficies partielles
for $i = 1 to $nb_item
$array [$i-1][2] = _GUICtrlListView_GetItemText($lv, $i-1, 2)
Next

;Lis les superficies partielles en %
for $i = 1 to $nb_item
$array [$i-1][3] = _GUICtrlListView_GetItemText($lv, $i-1, 3)/100
Next

;Lis les Hi
for $i = 1 to $nb_item
$array [$i-1][5] = _GUICtrlListView_GetItemText($lv, $i-1, 5)
Next

;Lis les di
for $i = 1 to $nb_item
$array [$i-1][6] = _GUICtrlListView_GetItemText($lv, $i-1, 6)
Next

;Calcul de la surface totale
$somme = 0

for $i = 1 to $nb_item
$somme = $somme + $array [$i-1][2]
Next
;Lis le périmètre
$perimetre = GUICtrlRead($perimetre_input)

;Calcul de la somme de sqrt ai*Di
$somme_sqrt_aidi = 0

for $i = 1 to $nb_item
$somme_sqrt_aidi = $somme_sqrt_aidi + sqrt($array [$i-1][3]*$array [$i-1][6])
Next


;Formules de calcul utilisées
$hmin = _GUICtrlListView_GetItemText($lv,0)
$Kc = 0.28 * ($perimetre / Sqrt($somme));Indice de compacité
$L1 = 1-(1.12/$Kc)^2
$L = (($Kc * sqrt($somme)) / 1.12 )*(1+Sqrt($L1));La longueur du réctangle équivalent
$Tc = ((4*Sqrt($somme))+(1.5*$L))/(0.8*Sqrt($hmoy-$hmin))
$Ip = $L^(-0.5)*($somme_sqrt_aidi)

GUICtrlSetData($Kc_label, Round($Kc,2))
GUICtrlSetData($L_label, Round($L,2)& " Km")
GUICtrlSetData($somme_label,$somme& " Km²")
GUICtrlSetData($Tc_label, Round($Tc,2)& " h")
GUICtrlSetData($Ip_label, Round($Ip,2))
EndIf

;===============================
;Tracé de la courbe
;================================

Case $msg = $Courbe_Dummy
Local $sel
_GUICtrlComboBox_GetLBText($C_box, _GUICtrlComboBox_GetCurSel($C_box), $sel)
if _GUICtrlListView_GetItemText($lv,0,4) = "" or $sel = "" Then
MsgBox(48,"","Data unknown or Color not specified")
Else
$gui_courbe = GUICreate("Hypsometric curve",800,598)

$pic = GUICtrlCreatePic("", 0, 0,800,578)
$hBmp = _WinAPI_LoadImage(_WinAPI_LoadLibrary("wcs.dll"), 6, $IMAGE_BITMAP, 800, 578, $LR_DEFAULTCOLOR)
GUICtrlSendMsg($pic, 0x0172, $IMAGE_BITMAP, $hBmp)

GUICtrlSetState($pic,$GUI_DISABLE)

$option = GUICtrlCreateMenu("Options")
$save_image = GUICtrlCreateMenuItem("Save the graph as ...", $option)

GUISetState(@SW_SHOW)

;=====================================================
;Création du Pen et lancement du GDU+
;=====================================================
_GDIPlus_Startup ()

$tension = GUICtrlRead($T_box)
Local $sel
_GUICtrlComboBox_GetLBText($C_box, _GUICtrlComboBox_GetCurSel($C_box), $sel)

if $sel = ("Blue") Then
$hPen = _GDIPlus_PenCreate (0xFF0000ec,GUICtrlRead($ep_box),2)
$color = ("0x0000ec")
ElseIf $sel = ("Red") Then
$hPen = _GDIPlus_PenCreate (0xFFFF0000,GUICtrlRead($ep_box),2)
$color = ("0xFF0000")
ElseIf $sel = ("Green") Then
$hPen = _GDIPlus_PenCreate (0xFF0c791e,GUICtrlRead($ep_box),2)
$color = ("0x0c791e")
EndIf

$hGraphics = _GDIPlus_GraphicsCreateFromHWND ($gui_courbe)





;Caclul des coordonnées des Si

$nb_line = _GUICtrlListView_GetItemCount($lv)
$h_min = _GUICtrlListView_GetItemText($lv,0,0)
$h_max = _GUICtrlListView_GetItemText($lv,$nb_line-1,1)
$D_h = $h_max - $h_min



Global $array_points [$nb_line+2][2]
$array_points [0][0] = $nb_line +1
For $i = 1 to $nb_line

$eval_x = Eval("S"&"i"&"_"&"x"&$i)
$eval_y = Eval("S"&"i"&"_"&"y"&$i)
$eval_x = Round((_GUICtrlListView_GetItemText($lv,$i-1,4)*714)/100,1) + 57
$eval_y = (Round((($h_max - _GUICtrlListView_GetItemText($lv,$i-1,0))*513)/$D_h,1)) + 29

$array_points [$i][0] = $eval_x
$array_points [$i][1] = $eval_y

Next

;Dernier points
$array_points [$nb_line+1][0] = 57
$array_points [$nb_line+1][1] = 29

$curv = _GDIPlus_GraphicsDrawCurve2($hGraphics, $array_points, $tension, $hPen)


;Placer les points rouges

$mx = 57
For $m = 1 To $nb_line +1

$my = Round($array_points [$m][1],0)

GUICtrlCreateIcon(@ScriptDir & "\wcs.dll", 2, $mx-12, $my, 10, 2)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel(_guictrllistview_getitemtext($lv,$m-1,0),$mx -40,$my-3)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

Next
GUICtrlCreateLabel(_guictrllistview_getitemtext($lv,$nb_line-1,1),17,26)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Sleep(500)
$hndl = WinGetHandle("Hypsometric curve")
AutoItSetOption ("PixelCoordMode",2)

Global $pixel [2] , $pixel2 [2] , $pixel3 [2]

;Recherche de 5%
$pixel[0] = 89
for $i = 1 to 10
$pixel = PixelSearch($pixel[0] + 1 ,0,95,578,$color,0,1,$hndl)

If $pixel[0] = 93 Then
ExitLoop
EndIf
Next
;Recherche de 95%
$pixel2[0] = 730
For $i = 1 to 10
$pixel2 = PixelSearch($pixel2[0] + 1,0,740,578,$color,0,1,$hndl)
If $pixel2[0] = 735 Then
ExitLoop
EndIf
Next
;Recherche de 50%
$pixel3[0] = 410
For $i = 1 to 10
$pixel3 = PixelSearch($pixel3[0] + 1,0,420,578,$color,0,1,$hndl)
If $pixel3[0] = 414 Then
ExitLoop
EndIf
Next


;Calcul de D5% , D95% et D50%
$D5 = Round( $h_max - ((($pixel[1] -29) * $D_h)/513),2)
$D95 = Round( $h_max - ((($pixel2[1] -29) * $D_h)/513),2)
$D50 = Round( $h_max - ((($pixel3[1] -29) * $D_h)/513),2)
;Calcul de la denivele
$Denivele = Round(($D5 - $D95),2)
;Calcul de Ig
$L = GUICtrlRead($L_label)
$Ig = Round ($Denivele / (10 * $L),2)
$Ds = Round($Ig * Sqrt(Guictrlread($somme_label)),2) *10



GUICtrlSetData($Ig_label, $Ig & " %")
GUICtrlSetData($Ds_label, $Ds & " m")
GUICtrlSetData($D_label, $D_h & " m")
GUICtrlSetData($Hmed_label, $D50 & " m")

If $Ds < 10 Then
Guictrlsetdata($relief_ds_label,"Class R1: Relief very low")
ElseIf 10 < $Ds And $Ds < 25 Then
Guictrlsetdata($relief_ds_label,"Class R2: Relief low")
ElseIf 25 < $Ds And $Ds < 50 Then
Guictrlsetdata($relief_ds_label,"Class R3: Relief relatively low")
ElseIf 50 < $Ds And $Ds < 100 Then
Guictrlsetdata($relief_ds_label,"Class R4: Moderate relief")
ElseIf 100 < $Ds And $Ds < 250 Then
Guictrlsetdata($relief_ds_label,"Class R5: Relief strong enough")
ElseIf 250 < $Ds And $Ds < 500 Then
Guictrlsetdata($relief_ds_label,"Class R6: Relief strong")
ElseIf $Ds > 500 Then
Guictrlsetdata($relief_ds_label,"Class R7: Relief very strong")
EndIf

If $Ig < 0.2 Then
Guictrlsetdata($relief_ig_label,"Class R1: Relief very low")
ElseIf 0.2 < $Ig And $Ig < 0.5 Then
Guictrlsetdata($relief_ig_label,"Class R2: Relief low")
ElseIf 0.5 < $Ig And $Ig < 1 Then
Guictrlsetdata($relief_ig_label,"Class R3: Relief relatively low")
ElseIf 1 < $Ig And $Ig < 2 Then
Guictrlsetdata($relief_ig_label,"Class R4: Moderate relief")
ElseIf 2 < $Ig And $Ig < 5 Then
Guictrlsetdata($relief_ig_label,"Class R5: Relief strong enough")
ElseIf 5 < $Ig And $Ig < 10 Then
Guictrlsetdata($relief_ig_label,"Class R6: Relief strong")
ElseIf $Ig > 10 Then
Guictrlsetdata($relief_ig_label,"Class R7: Relief very strong")
EndIf


While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
GUIDelete($gui_courbe)
ExitLoop

Case $msg = $save_image

MsgBox(64,"WCS 1.0 Light","Function not available")

EndSelect
WEnd
EndIf
;========================================
;SAVE
;========================================

Case $msg = $save

MsgBox(64,"WCS 1.0 Light","Function not available")
;========================================
;OPEN
;========================================
Case $msg = $open
MsgBox(64,"WCS 1.0 Light","Function not available")


;========================================
;ADD ITEM
;========================================
Case $msg = $add_dummy

_GUICtrlListView_AddItem($lv, "")

;========================================
;DELETE ITEM
;========================================
Case $msg = $del_dummy

$indexLV = ControlListView($gui, "", $lv, "GetSelected")
_GUICtrlListView_DeleteItem($lv,$indexLV)


;========================================
;HELP
;========================================
Case $msg = $help
ShellExecute(@ScriptDir & "\Help\Tutoriel WCS.chm")




;========================================
;EXIT
;========================================

Case $msg = $exit
Exit






EndSelect
WEnd




Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $hWndFrom, $iCode

$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
$iCode = DllStructGetData($tNMHDR, "Code")

Switch $hWndFrom
Case $lv
Switch $iCode
Case $NM_DBLCLK
Local $aHit = _GUICtrlListView_SubItemHitTest($lv)

If ($aHit[0] <> -1) And ($aHit[1] = 0) Then
$Item = $aHit[0]
$SubItem = 0
Local $aRect = _GUICtrlListView_GetItemRect($lv, $Item,0)
ElseIf ($aHit[0] <> -1) And ($aHit[1] > 0) Then
$Item = $aHit[0]
$SubItem = $aHit[1]
Local $aRect = _GUICtrlListView_GetSubItemRect($lv, $Item, $SubItem)
Else
Return $GUI_RUNDEFMSG
EndIf

Local $iItemText = _GUICtrlListView_GetItemText($lv, $Item, $SubItem)
Local $iLen = _GUICtrlListView_GetStringWidth($lv, $iItemText)
$hEdit = _GUICtrlEdit_Create($gui, $iItemText, $aRect[0] + 10, $aRect[1] + 29, $iLen + 50, 18, $Style)

_GUICtrlEdit_SetSel($hEdit, 0, -1)
_WinAPI_SetFocus($hEdit)
$hDC = _WinAPI_GetWindowDC($hEdit)
$hBrush = _WinAPI_CreateSolidBrush(0x0000FF)
FrameRect($hDC, 0, 0, $iLen + 50, 18, $hBrush)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc

Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
Local $stRect = DllStructCreate("int;int;int;int")

DllStructSetData($stRect, 1, $nLeft)
DllStructSetData($stRect, 2, $nTop)
DllStructSetData($stRect, 3, $nRight)
DllStructSetData($stRect, 4, $nBottom)

DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)
EndFunc

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $iCode = BitShift($wParam, 16)

Switch $lParam
Case $hEdit
Switch $iCode
Case $EN_KILLFOCUS
Local $iText = _GUICtrlEdit_GetText($hEdit)
_GUICtrlListView_SetItemText($lv, $Item, $iText, $SubItem)
_WinAPI_DeleteObject($hBrush)
_WinAPI_ReleaseDC($hEdit, $hDC)
_WinAPI_DestroyWindow($hEdit)

$Item = -1
$SubItem = 0
EndSwitch
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc

Func _Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $calcul_tableau
GUICtrlSetImage($iCtrlID, "wcs.dll",7)

Case $calcul
GUICtrlSetImage($iCtrlID, "wcs.dll",7)

Case $courbe
GUICtrlSetImage($iCtrlID, "wcs.dll",7)

Case $additem
GUICtrlSetImage($iCtrlID, "wcs.dll",16)

Case $delitem
GUICtrlSetImage($iCtrlID, "wcs.dll",13)

EndSwitch
EndFunc

Func _Leave_Hover_Proc($iCtrlID)
Switch $iCtrlID
Case $calcul_tableau
GUICtrlSetImage($iCtrlID, "wcs.dll",6)

Case $calcul
GUICtrlSetImage($iCtrlID, "wcs.dll",6)

Case $Courbe
GUICtrlSetImage($iCtrlID, "wcs.dll",6)

Case $additem
GUICtrlSetImage($iCtrlID, "wcs.dll",9)

Case $delitem
GUICtrlSetImage($iCtrlID, "wcs.dll",12)

EndSwitch
EndFunc

Func PrimaryDown_Proc($iCtrlID)
Switch $iCtrlID
Case $calcul_tableau
GUICtrlSetImage($iCtrlID, "wcs.dll",8)

Case $calcul
GUICtrlSetImage($iCtrlID, "wcs.dll",8)

Case $Courbe
GUICtrlSetImage($iCtrlID, "wcs.dll",8)

Case $additem
GUICtrlSetImage($iCtrlID, "wcs.dll",11)

Case $delitem
GUICtrlSetImage($iCtrlID, "wcs.dll",14)

EndSwitch
EndFunc

Func PrimaryUp_Proc($iCtrlID)
Switch $iCtrlID
Case $calcul_tableau
GUICtrlSetImage($iCtrlID, "wcs.dll",7)
GUICtrlSendToDummy($Tableau_Dummy)

Case $calcul
GUICtrlSetImage($iCtrlID, "wcs.dll",7)
GUICtrlSendToDummy($Calcul_Dummy)

Case $Courbe
GUICtrlSetImage($iCtrlID, "wcs.dll",7)
GUICtrlSendToDummy($Courbe_Dummy)

Case $additem
GUICtrlSetImage($iCtrlID, "wcs.dll",16)
GUICtrlSendToDummy($add_Dummy)

Case $delitem
GUICtrlSetImage($iCtrlID, "wcs.dll",13)
GUICtrlSendToDummy($del_Dummy)

EndSwitch
EndFunc
Edited by parazitenew

Share this post


Link to post
Share on other sites
Melba23

parazitenew,

I have no idea why one script works and one does not - I would have expected the UDF to have malfunctioned in this case just like in the earlier script as you reregister WM_COMMAND after having registered the UDF handler. The UDF is extremely complicated and I have come across some other scripts where it has not worked entirely as expected - I shall add this case to the list. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
parazitenew

Ok, thank you.

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  

×