PdcWindows.ActiveWindow: Difference between revisions
Created page with "== Declaration == ActiveWindow as PdcWindow == Description == Returns the window object of the active window == Notes == This property returns the window object for the..." |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
== Code example == | == Code example == | ||
Loop through the selected rows of the active window if it is the calculationlist and shows the calculation text. | Loop through the selected rows of the active window if it is the calculationlist and shows the calculation text.<br/> | ||
!!! Note !!! Do not use a message box before reading the active window's key values into a stringlist. The click on the message box will change the selection to only the last selected line.<br/> | |||
<br/> | |||
<source lang="vb"> | <source lang="vb"> | ||
Line 26: | Line 28: | ||
end if | end if | ||
Next | Next | ||
else | |||
msgbox "This script does not work with the opened window in PdC (Windowkey " & ActiveWindow.WindowKey & ")." & vbCrLf & _ | |||
"It works only with the calculationlist (Windowkey 32)." | |||
end if | end if | ||
set KeyValues = nothing | set KeyValues = nothing | ||
Line 31: | Line 36: | ||
set ActiveWindow = nothing | set ActiveWindow = nothing | ||
</source> | </source> | ||
<br/> | |||
vb.NET code example. | |||
<source lang="vb"> | |||
Dim ActiveWindow As PDCEXT.IPDCWindow = Nothing | |||
Dim KeyValues = Nothing | |||
Dim AO_INC As Integer | |||
ActiveWindow = pdc.App.Windows.ActiveWindow | |||
if ActiveWindow.WindowKey = "82" then 'Clocklines | |||
KeyValues = ActiveWindow.KeyValues | |||
For index = 0 To KeyValues.Count -1 | |||
AO_INC = KeyValues(index) | |||
Next | |||
else | |||
Msgbox("Open eerst het klokregelbestand.", vbExclamation) | |||
end if | |||
releaseObject(KeyValues) | |||
releaseObject(ActiveWindow) | |||
</source> | |||
<br/> | |||
To get the selected rows of a sub grid (materials or operations in the calculation list) Loop through the grids of the calculation list and show the grid names. Loop through the selected rows of the material and operation datagrid of the calculationlist and shows the selected ID's.<br/> | |||
You can use this script on list windows, but also on forms like "Relationcard" to get contacts, "Delivery note" to get certificates, "Invoice" to get payments and so on. <br/> | |||
!!! Note !!! Do not use a message box before reading the active window's key values into a stringlist. The click on the message box will change the selection to only the last selected line.<br/> | |||
<br/> | |||
<source lang="vb"> | |||
dim objActWin | |||
dim objActGrid | |||
set objActWin = pdc.Windows.ActiveWindow | |||
if objActWin.WindowKey = "32" then | |||
for lngCnt = 0 to objActWin.DataGrids.Count - 1 | |||
Memo1.Lines.Add objActWin.DataGrids.items(lngCnt) | |||
next | |||
Memo1.Lines.Add "" | |||
set objActGrid = objActWin.Datagrids.GetGridByName("PDCGrid2", "DM_ID") | |||
Memo1.Lines.Add objActGrid.SelectionKey | |||
for lngCnt = 0 to objActGrid.SelectedValues.Count - 1 | |||
Memo1.Lines.Add objActGrid.SelectedValues(lngCnt) | |||
next | |||
Memo1.Lines.Add "" | |||
set objActGrid = objActWin.Datagrids.GetGridByName("PDCGrid3", "DB_ID") | |||
Memo1.Lines.Add objActGrid.SelectionKey | |||
for lngCnt = 0 to objActGrid.SelectedValues.Count - 1 | |||
Memo1.Lines.Add objActGrid.SelectedValues(lngCnt) | |||
next | |||
end if | |||
</source> | |||
<br/> | |||
== Availability == | == Availability == | ||
Available from 4.0 onwards. | Available from 4.0 onwards. |
Latest revision as of 11:22, 2 August 2018
Declaration
ActiveWindow as PdcWindow
Description
Returns the window object of the active window
Notes
This property returns the window object for the active window in Plan-de-CAMpagne.
Code example
Loop through the selected rows of the active window if it is the calculationlist and shows the calculation text.
!!! Note !!! Do not use a message box before reading the active window's key values into a stringlist. The click on the message box will change the selection to only the last selected line.
dim activewindow
dim intTel
dim objCalc
dim KeyValues
set ActiveWindow = pdc.Windows.ActiveWindow
if ActiveWindow.WindowKey = "32" then 'Calculationlist
set KeyValues = ActiveWindow.KeyValues
for intTel = 0 to KeyValues.Count -1
set objCalc = pdc.OpenCalculation(KeyValues(intTel))
if IsValid(objCalc) then
MsgBox objCalc.Text
end if
Next
else
msgbox "This script does not work with the opened window in PdC (Windowkey " & ActiveWindow.WindowKey & ")." & vbCrLf & _
"It works only with the calculationlist (Windowkey 32)."
end if
set KeyValues = nothing
set objCalc = nothing
set ActiveWindow = nothing
vb.NET code example.
Dim ActiveWindow As PDCEXT.IPDCWindow = Nothing
Dim KeyValues = Nothing
Dim AO_INC As Integer
ActiveWindow = pdc.App.Windows.ActiveWindow
if ActiveWindow.WindowKey = "82" then 'Clocklines
KeyValues = ActiveWindow.KeyValues
For index = 0 To KeyValues.Count -1
AO_INC = KeyValues(index)
Next
else
Msgbox("Open eerst het klokregelbestand.", vbExclamation)
end if
releaseObject(KeyValues)
releaseObject(ActiveWindow)
To get the selected rows of a sub grid (materials or operations in the calculation list) Loop through the grids of the calculation list and show the grid names. Loop through the selected rows of the material and operation datagrid of the calculationlist and shows the selected ID's.
You can use this script on list windows, but also on forms like "Relationcard" to get contacts, "Delivery note" to get certificates, "Invoice" to get payments and so on.
!!! Note !!! Do not use a message box before reading the active window's key values into a stringlist. The click on the message box will change the selection to only the last selected line.
dim objActWin
dim objActGrid
set objActWin = pdc.Windows.ActiveWindow
if objActWin.WindowKey = "32" then
for lngCnt = 0 to objActWin.DataGrids.Count - 1
Memo1.Lines.Add objActWin.DataGrids.items(lngCnt)
next
Memo1.Lines.Add ""
set objActGrid = objActWin.Datagrids.GetGridByName("PDCGrid2", "DM_ID")
Memo1.Lines.Add objActGrid.SelectionKey
for lngCnt = 0 to objActGrid.SelectedValues.Count - 1
Memo1.Lines.Add objActGrid.SelectedValues(lngCnt)
next
Memo1.Lines.Add ""
set objActGrid = objActWin.Datagrids.GetGridByName("PDCGrid3", "DB_ID")
Memo1.Lines.Add objActGrid.SelectionKey
for lngCnt = 0 to objActGrid.SelectedValues.Count - 1
Memo1.Lines.Add objActGrid.SelectedValues(lngCnt)
next
end if
Availability
Available from 4.0 onwards.