a small program to capture any screen area you choose yourse

Everything else that doesn't fall into one of the other PB categories.
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

a small program to capture any screen area you choose yourse

Post by PAPIPP »

Hello to All

Here is a small program to capture any screen area you choose yourself
This PRG is unpretentious.

Operation:

1) Start the prg

2) You get a transparent window which can be moved and enlarged on demand.

3) when moving, as the area does not appear (In my option: Property Office XP)
This is the area defined when moving that sets the limits of the rectangle to capture.

4) After adjusting the window press F12 key release a menu you
ask the way, the name and type of file you want to save (BMP, JPG, PNG). (Default PNG)

5) You can repeat as many times as you like this.

6) To exit the PRG:
Click X in the title field.
Please note the transparent window is not always easy to spot.

7) In the title box, if you click - you minimize the window and if you click on zoom, you can capture the entire screen.

Code: Select all

    EnableExplicit
    UsePNGImageEncoder()
    UseJPEGImageEncoder()
    UseJPEG2000ImageEncoder()
    
    Enumeration
      #FEN=0
    EndEnumeration
    Global nb_p,hwnd,WWIN,WHIN,WWOUT,WHOUT,rcwin.rect,Hwindow
    Define eventID
    Macro SAVEIMAGE_M
      FichierParDefaut$="C:\"   ; Répertoire et fichier par défaut qui seront affichés
      Filtre$+"PNG (*.png)|*.png|"                   ; Premier filtre (index = 0)
      Filtre$+"Bmp (*.bmp)|*.bmp|"                   ; Deuxième filtre (index = 2)
      Filtre$+"Jpeg (*.jpg)|*.jpg|"                  ; Troisième filtre (index = 3)
      Filtre$+"Tous les fichiers (*.*)|*.*"          ; Quatrième filtre (index = 4)
      Filtre=0                                       ; utiliser  par défaut le premier des trois filtres possibles
      TITRE$="Choix du Chemin & donnez un fichier à sauvegarder sans le suffix"
      ltitr=Len(titre$)
      BOUC1:
      TITRE$+Space(10)
      Fichier$=SaveFileRequester(TITRE$,FichierParDefaut$,Filtre$,Filtre)
      If FICHIER$>""
        Index=SelectedFilePattern()
        Select index
          Case 0
            SaveImage(img,fichier$+".PNG",#PB_ImagePlugin_PNG)
          Case 1
            SaveImage(img,fichier$+".BMP",#PB_ImagePlugin_BMP)
          Case 2
            SaveImage(img,fichier$+".JPG",#PB_ImagePlugin_JPEG)
          Case 3
            SaveImage(img,fichier$+".PNG",#PB_ImagePlugin_PNG)
        EndSelect
      ElseIf Len(titre$)<ltitr+11
        Goto BOUC1
      Else
        MessageRequester("Apès 2 tentatives STOP","STOP STOP STOP")
        End
      EndIf
    EndMacro
    
    Macro BITBIT
      img=CreateImage(#PB_Any,WWIN,WHOUT)
      dc=GetDC_(0)
      HideWindow(#Fen,#True)
      ;   Delay(2000)
      Fdest=StartDrawing(ImageOutput(img))
        BitBlt_(Fdest,0,0,WWIN,WHOUT,dc,RCWIN\left,RCWIN\top,#SRCCOPY)
      StopDrawing()
      ReleaseDC_(0,dc)
      HideWindow(#Fen,#False)
      
      SAVEIMAGE_M
    EndMacro
    Procedure.l KeyboardHook(nCode,wParam,*p.KBDLLHOOKSTRUCT)
      Protected img.l,dc.l,Fdest,FichierParDefaut$,Filtre$,Filtre,TITRE$,Fichier$,Index,ltitr
      If wParam=#WM_KEYDOWN Or wParam=#WM_SYSKEYDOWN Or wParam=#WM_KEYUP Or wParam=#WM_SYSKEYUP
        If *p\flags=128 And *p\vkCode=123  ; vkcode de la touche F12 au relachement
          BITBIT
          ProcedureReturn 1
        EndIf
      EndIf
      ProcedureReturn CallNextHookEx_(0,nCode,wParam,*p)
    EndProcedure
    ; Hwindow=OpenWindow(#Fen,0,0,500,400,"Window",#PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
    Hwindow=OpenWindow(#Fen,10,10,500,400,"Ajuster la fenêtre & F12",#PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
    SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0);  SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0)
    StickyWindow(#Fen,1)
    If Hwindow
      SetWindowColor(#Fen,RGB(255,0,0))
      SetWindowLongPtr_(Hwindow,#GWL_EXSTYLE,#WS_EX_LAYERED | #WS_EX_TOPMOST)
      SetLayeredWindowAttributes_(HWindow,RGB(255,0,0),0,#LWA_COLORKEY); RGB(255,0,0) rouge est la couleur à ne pas faire apparaitre donc transparante
      Repeat
        nb_p+1
        Delay(1)
        EventID=WindowEvent()
        If EventID=#PB_Event_CloseWindow
          End
        EndIf
        If nb_p%100=0
          WWIN=WindowWidth(#Fen,#PB_Window_InnerCoordinate)
          WHIN=WindowHeight(#Fen,#PB_Window_InnerCoordinate)
          WWOUT=WindowWidth(#Fen,#PB_Window_FrameCoordinate)
          WHOUT=WindowHeight(#Fen,#PB_Window_FrameCoordinate)
          GetWindowRect_(HWindow,rcwin.rect)
        EndIf
      ForEver
    EndIf

good bye
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: a small program to capture any screen area you choose yo

Post by electrochrisso »

Very hand PAPIPP, you should post this in tips and tricks, I also notice that whatever is under the bar at the top of the capture window also get captured.

Here are my changes for testing, still needs a bit more work like getting the height of the bar, perhaps it would be better to find out the inner bounds of the capture window. :)
Line 44: img=CreateImage(#PB_Any,WWIN,WHOUT-20)
Line 49: BitBlt_(Fdest,0,0,WWIN,WHOUT,dc,RCWIN\left,(RCWIN\top)+20,#SRCCOPY)
PureBasic! Purely the best 8)
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

Re: a small program to capture any screen area you choose yo

Post by PAPIPP »

Opus can set the capture area according to your desires.

In my home area is defined when moving is an option: the XP property)
This is the area defined when moving that sets the limits of the rectangle to capture.

Good bye
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: a small program to capture any screen area you choose yo

Post by blueb »

PAPIPP wrote: ; 6) To exit the program:
; Click X in the title field.
; Please note the transparent window is Not always easy To spot.
very nice papipp :D

Perhaps you could display a semi-transparent screen until the user presses F12.

The program would then make the screen totally transparent, create a screen PNG,
then revert it to semi-transparent again... ready for the next view.

just a suggestion.

blueb
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: a small program to capture any screen area you choose yo

Post by electrochrisso »

I think your suggestion would work ok blueb, that way it can be easy to line up what is underneath the top bar, especially when capturing horizontal narrow stuff like an icon bar.
PureBasic! Purely the best 8)
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

Re: a small program to capture any screen area you choose yo

Post by PAPIPP »

Thank you to all

Here is the requested correction (semi-transparent option)
For a semitransparent three possibilities:
1) You run the prg in the absence of an external parameter you will be asked to provide the level of transparency
Complete transparency <50
Sem-transparency (50 <xxx <200) limited to 200 MAX
2) If you are on EDI impose a value as follows:
21) compiler option
22) Compile / run
23 executable commandline type a value between 0 and 255
Then you can run the prg
3) If you compile the prg
Prg.exe xxx (xxx value between 0 and 255)

Code: Select all

EnableExplicit
UsePNGImageEncoder()
UseJPEGImageEncoder()
UseJPEG2000ImageEncoder()

Enumeration
  #FEN=0
EndEnumeration
Global nb_p,hwnd,WWIN,WHIN,WWOUT,WHOUT,rcwin.rect,Hwindow
Define eventID,RESinp$,transp,nb_par,i
Macro SAVEIMAGE_M
  FichierParDefaut$="C:\"   ; Répertoire et fichier par défaut qui seront affichés
  Filtre$+"PNG (*.png)|*.png|"                   ; Premier filtre (index = 0)
  Filtre$+"Bmp (*.bmp)|*.bmp|"                   ; Deuxième filtre (index = 1)
  Filtre$+"Jpeg (*.jpg)|*.jpg|"                  ; Troisième filtre (index = 2)
  Filtre$+"Tous les fichiers (*.*)|*.*"          ; Quatrième filtre (index = 3)
  Filtre=0                                       ; utiliser  par défaut le premier des trois filtres possibles
  TITRE$="Choix du Chemin & donnez un fichier à sauvegarder sans le suffix"
  ltitr=Len(titre$)
  BOUC1:
  TITRE$+Space(10)
  Fichier$=SaveFileRequester(TITRE$,FichierParDefaut$,Filtre$,Filtre)
  If FICHIER$>""
    Index=SelectedFilePattern()
    Select index
      Case 0
        SaveImage(img,fichier$+".PNG",#PB_ImagePlugin_PNG)
      Case 1
        SaveImage(img,fichier$+".BMP",#PB_ImagePlugin_BMP)
      Case 2
        SaveImage(img,fichier$+".JPG",#PB_ImagePlugin_JPEG)
      Case 3
        SaveImage(img,fichier$+".PNG",#PB_ImagePlugin_PNG)
    EndSelect
  ElseIf Len(titre$)<ltitr+11
    Goto BOUC1
  Else
    MessageRequester("Apès 2 tentatives STOP","STOP STOP STOP")
    End
  EndIf
EndMacro

Macro BITBIT
  img=CreateImage(#PB_Any,WWIN,WHOUT)
  dc=GetDC_(0)
  HideWindow(#Fen,#True)
  ;   Delay(2000)
  Fdest=StartDrawing(ImageOutput(img))
    BitBlt_(Fdest,0,0,WWIN,WHOUT,dc,RCWIN\left,RCWIN\top,#SRCCOPY)
  StopDrawing()
  ReleaseDC_(0,dc)
  HideWindow(#Fen,#False)
  
  SAVEIMAGE_M
EndMacro
Procedure.l KeyboardHook(nCode,wParam,*p.KBDLLHOOKSTRUCT)
  Protected img.l,dc.l,Fdest,FichierParDefaut$,Filtre$,Filtre,TITRE$,Fichier$,Index,ltitr
  If wParam=#WM_KEYDOWN Or wParam=#WM_SYSKEYDOWN Or wParam=#WM_KEYUP Or wParam=#WM_SYSKEYUP
    If *p\flags=128 And *p\vkCode=123  ; vkcode de la touche F12 au relachement
      BITBIT
      ProcedureReturn 1
    EndIf
  EndIf
  ProcedureReturn CallNextHookEx_(0,nCode,wParam,*p)
EndProcedure
;*********************************** Recherche de paramètre *********************
NB_PAR=CountProgramParameters() ; nombre de paramètre
For i=0 To NB_par-1
  RESinp$=ProgramParameter(i)  ; le dernier paramètre sera pris en compte
Next
If resinp$=""
  RESinp$=InputRequester("Transparent ou semitransparent","Transparent <50  semitansparent 50<xxx<200","0")
EndIf
;***************************************************************************************************************
Hwindow=OpenWindow(#Fen,10,10,500,400,"Ajuster la fenêtre & F12",#PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
If Hwindow
  transp=Val(resinp$)
  If transp <50
    SetWindowColor(#Fen,RGB(255,0,0))
    SetWindowLongPtr_(Hwindow,#GWL_EXSTYLE,#WS_EX_LAYERED | #WS_EX_TOPMOST)
    SetLayeredWindowAttributes_(HWindow,RGB(255,0,0),0,#LWA_COLORKEY); RGB(255,0,0) rouge est la couleur à ne pas faire apparaitre donc transparante
  Else
    If transp>200
      transp=200
    EndIf
    SetWindowLongPtr_(Hwindow,#GWL_EXSTYLE,GetWindowLongPtr_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_LAYERED)
    ; peut-on ne rendre que la partie intérieure transparente  ???
    SetLayeredWindowAttributes_(Hwindow,0,transp,#LWA_ALPHA)
  EndIf
  SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0);  SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0)
  StickyWindow(#Fen,1)
  Repeat
    nb_p+1
    Delay(1)
    EventID=WindowEvent()
    If EventID=#PB_Event_CloseWindow
      End
    EndIf
    If nb_p%100=0
      WWIN=WindowWidth(#Fen,#PB_Window_InnerCoordinate)
      WHIN=WindowHeight(#Fen,#PB_Window_InnerCoordinate)
      WWOUT=WindowWidth(#Fen,#PB_Window_FrameCoordinate)
      WHOUT=WindowHeight(#Fen,#PB_Window_FrameCoordinate)
      GetWindowRect_(HWindow,rcwin.rect)
    EndIf
  ForEver
EndIf
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: a small program to capture any screen area you choose yo

Post by blueb »

:D
Good stuff PAPIPP. Works like a charm.

A few improvement ideas that anyone (you've done enough) can make...

Add a Preference file to save the users information:
- desired transparency
- desired file save location (program remembers last location)

and perhaps a splash screen to give the user some idea of what the program does.

blueb
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: a small program to capture any screen area you choose yo

Post by electrochrisso »

Yep! works good here too, better way to go than my idea, to be able to better capture top of the screen. :)
PureBasic! Purely the best 8)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: a small program to capture any screen area you choose yo

Post by IdeasVacuum »

Nice work! 8) I was surprised to see the entire window, including the title bar, affected by the transparency setting.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: a small program to capture any screen area you choose yo

Post by Tenaja »

Nice tool; thank you for sharing.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: a small program to capture any screen area you choose yo

Post by Danilo »

What about removing the window titlebar? (like this)
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

Re: a small program to capture any screen area you choose yo

Post by PAPIPP »

Hello Danilo

Okay thank you.
But the area can not be resized misses the parameter #PB_Window_SizeGadget
Or if it is on the title bar reappears.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: a small program to capture any screen area you choose yo

Post by Danilo »

PAPIPP wrote:But the area can not be resized misses the parameter #PB_Window_SizeGadget
The corners are for resizing, and you could add the sides as well.

BTW, there is also Snipping Tool (Video) included with Windows (Vista+), usually located in Windows/Systems32/
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

Re: a small program to capture any screen area you choose yo

Post by PAPIPP »

Hello Danilo

With XP SP3 window can be moved, but you can not resize
By cons with some modifications of the program, it works perfectly
With these changes, we can remove the callback.

Thank you Danilo. I'll try to put this program in the capture.

Code: Select all

Enumeration 
  #FEN=2
  #POP
  #BOXSIZE=8
EndEnumeration 
Hwindow=OpenWindow(#FEN, 0, 0, 512, 512, "", #PB_Window_BorderLess | #WS_SIZEBOX | #PB_Window_ScreenCentered)
If hwindow
  StickyWindow(#FEN,#True)
  WID=WindowID(#FEN)
  SetWindowColor(#FEN,RGB(200,250,255)) ; RGB(120,120,120) ;RGB(0,100,255)
  SetWindowLongPtr_(WID,#GWL_EXSTYLE,GetWindowLongPtr_(WID,#GWL_EXSTYLE) | #WS_EX_LAYERED)
  SetLayeredWindowAttributes_(Hwindow,RGB(70,0,0),120,#LWA_ALPHA)  ; RGB(100,0,0)
  CreatePopupMenu(#POP)
  MenuItem(1,"Quit")
  MenuItem(2,"Cancel")
  SetClassLongPtr_(Hwindow,#GCL_HCURSOR,LoadCursor_(0,#IDC_SIZEALL))
  wh=WindowHeight(#FEN)
  ww=WindowWidth(#FEN)
  ; ********* on peut supprimer les commentaires des 8 instructions suivantes  **************
  ; ********* may delete comments following 8 instructions **************
  ; CanvasGadget(0,0,0,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(1,ww/2-#BOXSIZE/2,0,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(2,ww-#BOXSIZE,0,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(3,ww-#BOXSIZE,wh/2-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(4,ww-#BOXSIZE,wh-#BOXSIZE,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(5,ww/2-#BOXSIZE/2,wh-#BOXSIZE,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(6,0,wh-#BOXSIZE,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  ; CanvasGadget(7,0,wh/2-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)
  Repeat
    EventID=WaitWindowEvent()
    Select EventID
      Case #WM_LBUTTONDOWN
        GetCursorPos_(@pt.POINT)
        cursor=(pt\x<<16) | pt\y
        SendMessage_(Hwindow,#WM_NCLBUTTONDOWN,#HTCAPTION,cursor)
      Case #WM_RBUTTONUP
        DisplayPopupMenu(#POP,WID)
      Case #PB_Event_Menu
        Select EventMenu()
          Case 1
            End
        EndSelect
    EndSelect
  Until EventID=#PB_Event_CloseWindow
EndIf
PAPIPP
User
User
Posts: 49
Joined: Mon Aug 17, 2009 10:48 pm
Location: France

Re: a small program to capture any screen area you choose yo

Post by PAPIPP »

Hello everyone

An idea of ​​Danilo here's the catch with no title bar window.
It can be moved and resized with the left mouse button.
To capture after placing the window type and sized F12.

PS: Transparency can be modified and the background color as the PRG.
To exit press the right button and click Quit.

Code: Select all

EnableExplicit
Enumeration
  #FEN=2
  #POP
  #BOXSIZE=8
EndEnumeration
UsePNGImageEncoder()
UseJPEGImageEncoder()
UseJPEG2000ImageEncoder()
Global nb_p,hwnd,WWIN,WHIN,WWOUT,WHOUT,rcwin.rect,Hwindow
Define eventID,RESinp$,transp,nb_par,i,WID, PT.point, cursor
Macro SAVEIMAGE_M
  FichierParDefaut$="C:\"   ; Répertoire et fichier par défaut qui seront affichés
  Filtre$+"PNG (*.png)|*.png|"                   ; Premier filtre (index = 0)
  Filtre$+"Bmp (*.bmp)|*.bmp|"                   ; Deuxième filtre (index = 1)
  Filtre$+"Jpeg (*.jpg)|*.jpg|"                  ; Troisième filtre (index = 2)
  Filtre$+"Tous les fichiers (*.*)|*.*"          ; Quatrième filtre (index = 3)
  Filtre=0                                       ; utiliser  par défaut le premier des trois filtres possibles
  TITRE$="Choix du Chemin & donnez un fichier à sauvegarder sans le suffix"
  ltitr=Len(titre$)
  BOUC1:
  TITRE$+Space(10)
  Fichier$=SaveFileRequester(TITRE$,FichierParDefaut$,Filtre$,Filtre)
  If FICHIER$>""
    Index=SelectedFilePattern()
    Select index
      Case 0
        SaveImage(img,fichier$+".PNG",#PB_ImagePlugin_PNG)
      Case 1
        SaveImage(img,fichier$+".BMP",#PB_ImagePlugin_BMP)
      Case 2
        SaveImage(img,fichier$+".JPG",#PB_ImagePlugin_JPEG)
      Case 3
        SaveImage(img,fichier$+".PNG",#PB_ImagePlugin_PNG)
    EndSelect
  ElseIf Len(titre$)<ltitr+11
    Goto BOUC1
  Else
    MessageRequester("Apès 2 tentatives STOP","STOP STOP STOP")
    End
  EndIf
EndMacro

Macro BITBIT
  ;       img=CreateImage(#PB_Any,WWIN,WHOUT)
  img=CreateImage(#PB_Any,WWOUT,WHOUT)
  dc=GetDC_(0)
  HideWindow(#Fen,#True)
  ;   Delay(2000)
  Fdest=StartDrawing(ImageOutput(img))
    ;         BitBlt_(Fdest,0,0,WWIN,WHOUT,dc,RCWIN\left,RCWIN\top,#SRCCOPY)
    BitBlt_(Fdest,0,0,WWOUT,WHOUT,dc,RCWIN\left,RCWIN\top,#SRCCOPY)
  StopDrawing()
  ReleaseDC_(0,dc)
  HideWindow(#Fen,#False)
 
  SAVEIMAGE_M
EndMacro
Procedure.l KeyboardHook(nCode,wParam,*p.KBDLLHOOKSTRUCT)
  Protected img.l,dc.l,Fdest,FichierParDefaut$,Filtre$,Filtre,TITRE$,Fichier$,Index,ltitr
  If wParam=#WM_KEYDOWN Or wParam=#WM_SYSKEYDOWN Or wParam=#WM_KEYUP Or wParam=#WM_SYSKEYUP
    If *p\flags=128 And *p\vkCode=123  ; vkcode de la touche F12 au relachement
      BITBIT
      ProcedureReturn 1
    EndIf
  EndIf
  ProcedureReturn CallNextHookEx_(0,nCode,wParam,*p)
EndProcedure

Hwindow=OpenWindow(#FEN,0,0,512,512,"",#PB_Window_BorderLess | #WS_SIZEBOX | #PB_Window_ScreenCentered)
If hwindow
  StickyWindow(#FEN,#True)
  WID=WindowID(#FEN)
  ;************************* En modifiant les valeurs de RGB ci-dessous  vous pouvez modifier la couleur du fond de la fenêtre **************************
  ;   SetWindowColor(#FEN,RGB(200,250,255)) ; RGB(120,120,120) ;RGB(0,100,255) ; Vous pouvez modifier la couleur du fond
  SetWindowLongPtr_(WID,#GWL_EXSTYLE,GetWindowLongPtr_(WID,#GWL_EXSTYLE) | #WS_EX_LAYERED)
  SetLayeredWindowAttributes_(Hwindow,0,100,#LWA_ALPHA) ; ******** Vous pouvez rendre la transparence plus ou moins importante *********
  CreatePopupMenu(#POP)
  MenuItem(1,"Quit")
  MenuItem(2,"Capturer F12")
  SetClassLongPtr_(Hwindow,#GCL_HCURSOR,LoadCursor_(0,#IDC_SIZEALL))
 
  ; ********* on peut supprimer les commentaires des 10 instructions suivantes  **************
  ;   WHOUT=WindowHeight(#FEN,#PB_Window_FrameCoordinate)
  ;   WWOUT=WindowWidth(#FEN,#PB_Window_FrameCoordinate)
  ;   CanvasGadget(0,-#BOXSIZE/2,-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)                   ; Haut Gauche
  ;   CanvasGadget(1,WWOUT/2-#BOXSIZE/2,-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)            ; Haut Milieu
  ;   CanvasGadget(2,WWOUT-#BOXSIZE,-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)                ; Haut Droit
  ;   CanvasGadget(3,WWOUT-#BOXSIZE,WHOUT/2-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)         ; Milieu Droit
  ;   CanvasGadget(4,WWOUT-#BOXSIZE,WHOUT-#BOXSIZE,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)             ; Bas Droit
  ;   CanvasGadget(5,WWOUT/2-#BOXSIZE/2,WHOUT-#BOXSIZE,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)         ; Bas milieu
  ;   CanvasGadget(6,-#BOXSIZE/2,WHOUT-#BOXSIZE,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)                ; Bas gauche
  ;   CanvasGadget(7,-#BOXSIZE/2,WHOUT/2-#BOXSIZE/2,#BOXSIZE,#BOXSIZE,#PB_Canvas_Border)            ; Milieu gauche
  ; ********* on peut supprimer les commentaires des 10 instructions Ci-dessus **************
 
  SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0);  SetWindowsHookEx_(#WH_KEYBOARD_LL,@KeyboardHook(),GetModuleHandle_(0),0)
 
  Repeat
;     EventID=WindowEvent()
    EventID=WaitWindowEvent(2)
; *********** Option ci dessous à tester contre l'option   Case #PB_Event_SizeWindow , #PB_Event_MoveWindow un peu plus loin  *********
;     Delay(1)
;     nb_p+1
;     If nb_p%50=0
;       WWIN=WindowWidth(#Fen,#PB_Window_InnerCoordinate)
;       WHIN=WindowHeight(#Fen,#PB_Window_InnerCoordinate)
;       WWOUT=WindowWidth(#Fen,#PB_Window_FrameCoordinate)
;       WHOUT=WindowHeight(#Fen,#PB_Window_FrameCoordinate)
;       GetWindowRect_(HWindow,rcwin.rect)
;     EndIf 
    Select EventID
      Case #WM_LBUTTONDOWN
        GetCursorPos_(@pt.POINT)
        cursor=(pt\x<<16) | pt\y
        SendMessage_(Hwindow,#WM_NCLBUTTONDOWN,#HTCAPTION,cursor)
      Case #WM_RBUTTONUP
        DisplayPopupMenu(#POP,WID)
      Case #PB_Event_Menu
        Select EventMenu()
          Case 1
            End
        EndSelect
              Case #PB_Event_SizeWindow , #PB_Event_MoveWindow
;               WWIN=WindowWidth(#Fen,#PB_Window_InnerCoordinate) ;  Largeur de la fenêtre sans les bordures
;               WHIN=WindowHeight(#Fen,#PB_Window_InnerCoordinate) ; Hauteur de la fenêtre sans les bordures
              WWOUT=WindowWidth(#Fen,#PB_Window_FrameCoordinate)   : ;Largeur de toute la fenêtre
              WHOUT=WindowHeight(#Fen,#PB_Window_FrameCoordinate)  ;  Hauteur de toute la fenêtre
              GetWindowRect_(HWindow,rcwin.rect)
    EndSelect
  Until EventID=#PB_Event_CloseWindow
EndIf
Post Reply