Page 1 of 1

Having probs with SetGadgetText ?

Posted: Thu Dec 16, 2021 11:05 pm
by vmars316
Hello ,
Having probs with SetGadgetText
after GetStartupInfo_(si.STARTUPINFO) .
What am I doing wrong ? Thanks

Code: Select all

; Purebasic - 5.73  https://www.purebasic.fr/english/index.php
Global Window_0
Global ListAvailableFilesBtn , SaveListBtn , CopyFilesBtn , FilesListView , FilesAvailableLV , FilesToCopyLV , ExitBtn , StatusArea
Global ReadThisFile$ , WriteTheseFile$ = "CopyTheseFiles.txt" , OneEditLine$ , FilesCopied = 0 , StatusArea$ 
Global CurrentDIR$ = GetCurrentDirectory() , EditorAreaItemsCOUNT = 0 , CopyToCount = 0
Global FoundCopyTo = 0 , CopyToFolder$ , CopyFromFolder$ , CopyTo$ , CopyFrom$ , CopyToArea , CopyFromArea
Global FolderAddresses$ = "FolderAddresses.txt" , BrowseBtn1 , BrowseBtn1_Clicked = #False , BrowseBtn2 , BrowseBtn2_Clicked = #False
Global CurrentDirElement$ , WhichAvailableItemClicked = 0 , CopyThisLVItem$
Global CurrentPath1$ = "" , CurrentPath2$ = "" , CheckBox1 , CheckBox2 , CreateThisFile$ 
Global Result = 0 , Result1 = 0 , Result2 = 0 , Result3 = 0 , WhileFilesToCopy = 0 , NextLineToCopy = 0 
Global FromLength = 0 , ToLength = 0 , FromAreaPath$ = "" , ToAreaPath$ = "" 
Global FromPosition = 0 , ToPosition = 0 , ShortcutFromArea$ , ShortcutToArea$

Declare browseBtn1_clicked()
Declare browseBtn2_clicked()
Declare ShortcutCheck()
Declare OpenWindow_0(x = 0, y = 0, width = 600, height = 800)
;Declare 


Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 800)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "CopyFilesTo  2.0", #PB_Window_SystemMenu)
  SetWindowColor(Window_0, RGB(128,128,128))
  
  CopyFromArea = EditorGadget(#PB_Any, 62, 10, 425, 23 )
    SetGadgetItemText(CopyFromArea, 0, "" )  ; ShortcutFromArea$
  CopyFromLabel = TextGadget(#PB_Any, 20, 10, 38, 23, " FROM")
  
  CopyToArea   = EditorGadget(#PB_Any, 62, 40, 425, 23 )
    SetGadgetItemText(CopyToArea, 0, "" )
  CopyToLabel   = TextGadget(#PB_Any, 20, 40, 38, 23 , "       TO")
  
  BrowseBtn1 = ButtonGadget(#PB_Any, 508, 10, 65, 23, "Or Browse")
   GadgetToolTip(BrowseBtn1 , "Browse for FROM Folder")
  BrowseBtn2 = ButtonGadget(#PB_Any, 508, 40, 65, 23, "Or Browse")
  GadgetToolTip(BrowseBtn2 , ShortcutFromArea$)
  
    MessageRequester("Procedure OpenWindow()", ShortcutFromArea$)
   SetGadgetText(CopyFromArea, ShortcutFromArea$ )  ; ShortcutFromArea$
    MessageRequester("(GetGadgetText(CopyFromAre))", GetGadgetText(CopyFromAre) )
   SetGadgetItemText(CopyFromArea, 0 , ShortcutFromArea$ )  ; ShortcutFromArea$
    MessageRequester("(GetGadgetItemText(CopyFromAre))", GetGadgetItemText(CopyFromAre , 0))

EndProcedure ; Procedure OpenWindow_
;
Procedure browseBtn1_clicked()
EndProcedure ; browseBtn_clicked()  
;
Procedure browseBtn2_clicked()
EndProcedure ; browseBtn2_clicked()  
;
;
Procedure ShortcutCheck()
  #STARTF_TITLESHORTCUT = $800
  GetStartupInfo_(si.STARTUPINFO)
  If si\dwFlags & #STARTF_TITLESHORTCUT = #STARTF_TITLESHORTCUT
    ShortcutFromArea$ = (PeekS(si\lpTitle)) 
;    MessageRequester("Procedure ShortcutCheck()", ShortcutFromArea$)
  EndIf
EndProcedure ; ShortcutCheck()

ShortcutCheck()
OpenWindow_0()


Repeat

  Select WaitWindowEvent()

    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case ExitBtn
          Quit = 1
          
        Case BrowseBtn1
          browseBtn1_clicked()
          
        Case BrowseBtn2
          browseBtn2_clicked()
          
      EndSelect

    Case #PB_Event_CloseWindow
      Quit = 1

  EndSelect

  If Quit = 1
    End
  EndIf
  Until Quit = 1 

Re: Having probs with SetGadgetText ?

Posted: Thu Dec 16, 2021 11:18 pm
by mk-soft
EnableExplicit helps
MessageRequester("(GetGadgetText(CopyFromAre))", GetGadgetText(CopyFromAre) )
and more ... :wink:

Re: Having probs with SetGadgetText ?

Posted: Fri Dec 17, 2021 1:09 am
by vmars316
Thanks ,
"EnableExplicit helps" yes , cleared up some things .

But I am now having probs with GetStartupInfo_(si.STARTUPINFO)

How do I define "si" , no info in help or Docs for GetStartupInfo_ ?

Thanks

Re: Having probs with SetGadgetText ?

Posted: Fri Dec 17, 2021 1:15 am
by BarryG
vmars316 wrote: Fri Dec 17, 2021 1:09 amHow do I define "si"
By using the whole definition:

Code: Select all

EnableExplicit

Procedure ShortcutCheck()
  #STARTF_TITLESHORTCUT = $800
  Define ShortcutFromArea$
  Define si.STARTUPINFO
  GetStartupInfo_(si.STARTUPINFO)
  If si\dwFlags & #STARTF_TITLESHORTCUT
    ShortcutFromArea$ = (PeekS(si\lpTitle)) 
  EndIf
EndProcedure

ShortcutCheck()
Note also that you don't need to check #STARTF_TITLESHORTCUT against itself (I removed it above).

Re: Having probs with SetGadgetText ?

Posted: Fri Dec 17, 2021 4:13 pm
by vmars316
NO errors , but it returns "" . Nada .

Code: Select all

    MessageRequester("Procedure OpenWindow()", ShortcutFromArea2$)
   SetGadgetText(CopyFromArea, ShortcutFromArea2$ )  ; ShortcutFromArea$
    MessageRequester("(GetGadgetText(CopyFromArea2))", GetGadgetText(CopyFromArea) )
   SetGadgetItemText(CopyFromArea, 0 , ShortcutFromArea2$ )  ; ShortcutFromArea$
    MessageRequester("(GetGadgetItemText(CopyFromArea)2)", GetGadgetItemText(CopyFromArea , 0))

Code: Select all

; Purebasic - 5.73  https://www.purebasic.fr/english/index.php
Global Window_0
Global ListAvailableFilesBtn , SaveListBtn , CopyFilesBtn , FilesListView , FilesAvailableLV , FilesToCopyLV , ExitBtn , StatusArea
Global ReadThisFile$ , WriteTheseFile$ = "CopyTheseFiles.txt" , OneEditLine$ , FilesCopied = 0 , StatusArea$ 
Global CurrentDIR$ = GetCurrentDirectory() , EditorAreaItemsCOUNT = 0 , CopyToCount = 0
Global FoundCopyTo = 0 , CopyToFolder$ , CopyFromFolder$ , CopyTo$ , CopyFrom$ , CopyToArea , CopyFromArea
Global FolderAddresses$ = "FolderAddresses.txt" , BrowseBtn1 , BrowseBtn1_Clicked = #False , BrowseBtn2 , BrowseBtn2_Clicked = #False
Global CurrentDirElement$ , WhichAvailableItemClicked = 0 , CopyThisLVItem$
Global CurrentPath1$ = "" , CurrentPath2$ = "" , CheckBox1 , CheckBox2 , CreateThisFile$ 
Global Result = 0 , Result1 = 0 , Result2 = 0 , Result3 = 0 , WhileFilesToCopy = 0 , NextLineToCopy = 0 
Global FromLength = 0 , ToLength = 0 , FromAreaPath$ = "" , ToAreaPath$ = "" , CopyFromLabel , CopyToLabel
Global FromPosition = 0 , ToPosition = 0 , ShortcutToArea$  , ShortcutFromArea2$ , Quit = 0

Declare browseBtn1_clicked()
Declare browseBtn2_clicked()
Declare ShortcutCheck()
Declare OpenWindow_0(x = 0, y = 0, width = 600, height = 800)
;Declare 

EnableExplicit

Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 800)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "CopyFilesTo  2.0", #PB_Window_SystemMenu)
  SetWindowColor(Window_0, RGB(128,128,128))
  
  CopyFromArea = EditorGadget(#PB_Any, 62, 10, 425, 23 )
    SetGadgetItemText(CopyFromArea, 0, "" )  ; ShortcutFromArea$
  CopyFromLabel = TextGadget(#PB_Any, 20, 10, 38, 23, " FROM")
  
  CopyToArea   = EditorGadget(#PB_Any, 62, 40, 425, 23 )
    SetGadgetItemText(CopyToArea, 0, "" )
  CopyToLabel   = TextGadget(#PB_Any, 20, 40, 38, 23 , "       TO")
  
  BrowseBtn1 = ButtonGadget(#PB_Any, 508, 10, 65, 23, "Or Browse")
   GadgetToolTip(BrowseBtn1 , "Browse for FROM Folder")
  BrowseBtn2 = ButtonGadget(#PB_Any, 508, 40, 65, 23, "Or Browse")
  GadgetToolTip(BrowseBtn2 , "Browse for TO Folder")
  
    MessageRequester("Procedure OpenWindow()", ShortcutFromArea2$)
   SetGadgetText(CopyFromArea, ShortcutFromArea2$ )  ; ShortcutFromArea$
    MessageRequester("(GetGadgetText(CopyFromArea2))", GetGadgetText(CopyFromArea) )
   SetGadgetItemText(CopyFromArea, 0 , ShortcutFromArea2$ )  ; ShortcutFromArea$
    MessageRequester("(GetGadgetItemText(CopyFromArea)2)", GetGadgetItemText(CopyFromArea , 0))

EndProcedure ; Procedure OpenWindow_
;
Procedure browseBtn1_clicked()
EndProcedure ; browseBtn_clicked()  
;
Procedure browseBtn2_clicked()
EndProcedure ; browseBtn2_clicked()  
;

Procedure ShortcutCheck()
  #STARTF_TITLESHORTCUT = $800
  Define ShortcutFromArea1$
  Define si.STARTUPINFO
  GetStartupInfo_(si.STARTUPINFO)
  If si\dwFlags & #STARTF_TITLESHORTCUT
    ShortcutFromArea1$ = (PeekS(si\lpTitle)) 
    ShortcutFromArea2$ = ShortcutFromArea1$
  EndIf
EndProcedure

ShortcutCheck()
OpenWindow_0()


Repeat

  Select WaitWindowEvent()

    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case ExitBtn
          Quit = 1
          
        Case BrowseBtn1
          browseBtn1_clicked()
          
        Case BrowseBtn2
          browseBtn2_clicked()
          
      EndSelect

    Case #PB_Event_CloseWindow
      Quit = 1

  EndSelect

  If Quit = 1
    End
  EndIf
  Until Quit = 1 

Re: Having probs with SetGadgetText ?

Posted: Tue Dec 21, 2021 9:11 pm
by vmars316
I am at a stand still :
This returns nothing to ShortcutFromArea1$

ShortcutFromArea$ = (PeekS(si\lpTitle))

Code: Select all

Procedure ShortcutCheck()
  #STARTF_TITLESHORTCUT = $800
  Define ShortcutFromArea1$
  Define si.STARTUPINFO
  GetStartupInfo_(si.STARTUPINFO)
  If si\dwFlags & #STARTF_TITLESHORTCUT
    ShortcutFromArea1$ = (PeekS(si\lpTitle)) 
    ShortcutFromArea2$ = ShortcutFromArea1$
  EndIf
EndProcedure

Re: Having probs with SetGadgetText ?

Posted: Tue Dec 21, 2021 10:49 pm
by infratec
This works here:

Code: Select all


#STARTF_TITLEISLINKNAME = $00000800



Procedure.s ShortcutCheck()
  
  Protected ShortcutPath$
  Protected si.STARTUPINFO
  
  GetStartupInfo_(@si)
  If si\dwFlags & #STARTF_TITLEISLINKNAME
    If si\lpTitle
      ShortcutPath$ = PeekS(si\lpTitle)
    EndIf
  EndIf
  
  ProcedureReturn ShortcutPath$
  
EndProcedure


MessageRequester("Info", "Called by:" + #LF$ + ShortcutCheck())
Win 10 x64 PB 5.73 x86 link to exe on desktop.
Result:
Called by:
C:\Users\xxx\Desktop\ShortcutTest.lnk
Btw.: GetStartupInfo_ () is not a PB procedure so you get no info about it in the PB help .
It is a Windows API call.
Look at WIndows docs:

https://docs.microsoft.com/en-us/window ... artupinfow
https://docs.microsoft.com/en-us/window ... artupinfoa

Re: Having probs with SetGadgetText ?

Posted: Mon Mar 11, 2024 3:47 pm
by vmars316
Thanks infratec...