Page 1 of 1

What's changed in this code between 4.20 & 4.30 [Resolved]

Posted: Tue Nov 24, 2009 5:37 pm
by Kwai chang caine
Post removed because the real problem is in the code above :D

Re: What's changed for the DATA between v4.20 and 4.30 ??

Posted: Tue Nov 24, 2009 6:02 pm
by Kaeru Gaman
I don't understand what you want. Image

.. some thing I see: take that DataSection out of the Procedure.
don't park a lorry in a kitchen.

Re: What's changed for the DATA between v4.20 and 4.30 ??

Posted: Tue Nov 24, 2009 6:12 pm
by Kwai chang caine
In fact i have found the problem...but i can't fix it :oops:
The problem is not in the DataSection but in the code who is created by the SkinGenerator

I use the splendid code of MISCHA who create mask for skin windows.
The problem it's that this code don't generate a good PBI when he works into the v4.30 and 4.40.
HE works only with v4.20 and when i rin the PBI created in the 4.20...

Somebody know why ???
What is changed between the v4.20 and 4.30 ???

Code: Select all

; Author: Mischa (updated for PB3.93 by Donald)
; Date: 04. January 2004
; OS: Windows
; Demo: No

; Creates a .pbi file in the directory of a bitmap, which should
; be used as skin/background for a window...
; The created .pbi file will contain the calculated window mask data
; as well include the converted bitmap (into .png format).
; Note: an example for using the created .pbi file can be found at
; "WindowSkin_Example.pb" !

; Modifié par KCC (Adaptation en 4.10 + Indentation de ce code et du code masque généré + Rajout des surlignages de label
; + Modification chemin du fichier dans le chemin de l'image) + Rajout du module de selection couleur de GILLOU


Procedure WindowCallBack(WindowId, Message, lParam, wParam) 
 
 If Message = #WM_PAINT 
  StartDrawing(WindowOutput(0)) 
  DrawImage(ImageID(1), 0, 0) 
  StopDrawing() 
 EndIf 
 
 ProcedureReturn #PB_ProcessPureBasicEvents 

EndProcedure 

UsePNGImageEncoder() 
UsePNGImageDecoder() 

Structure myBITMAPINFO 
 bmiHeader.BITMAPINFOHEADER 
 bmiColors.RGBQUAD[1] 
EndStructure 

Structure RGB 
 v.l 
EndStructure 

Procedure CreateMask() 

 hDC = StartDrawing(ImageOutput(1)) 
 main  = CreateRectRgn_(0,0,0,0) 
 picl_X = ImageWidth(1) 
 picl_Y = ImageHeight(1) 
 mem = AllocateMemory(picl_X*picl_Y*4) 
 bmi.myBITMAPINFO 
 bmi\bmiHeader\biSize   = SizeOf(BITMAPINFOHEADER) 
 bmi\bmiHeader\biWidth  = picl_X 
 bmi\bmiHeader\biHeight = picl_Y 
 bmi\bmiHeader\biPlanes = 1 
 bmi\bmiHeader\biBitCount = 32 
 bmi\bmiHeader\biCompression = #BI_RGB 
 GetDIBits_(hDC,ImageID(1),1,picl_Y-1,mem,bmi,#DIB_RGB_COLORS) 
 *pixel.RGB = mem 
 trans.RGB 
 trans\v = *pixel\v 
 
 If Blue (trans\v)=255 And Green (trans\v)=0 And Red (trans\v)=0 : messag$= " -> Rouge" 
 ElseIf Blue (trans\v)=0 And Green (trans\v)=255 And Red (trans\v)=0 : messag$= " -> Vert" 
 ElseIf Blue (trans\v)=0 And Green (trans\v)=0 And Red (trans\v)=255 : messag$= " -> Bleu" 
 ElseIf Blue (trans\v)=255 And Green (trans\v)=255 And Red (trans\v)=255 : messag$= " -> Blanc" 
 ElseIf Blue (trans\v)=0 And Green (trans\v)=0 And Red (trans\v)=0 : messag$= " -> Noir" 
 EndIf 
 coulon = MessageRequester ( "Sélection de la couleur du masque" , "Couleur détectée : " + "Rouge : " + Str ( Blue (trans\v))+ " ; Vert : " + Str ( Green (trans\v))+ " ; Bleu : " + Str ( Red (trans\v))+messag$+ Chr (13)+ Chr (13)+ "Acceptez-vous cette couleur? (Oui : Utiliser la couleur ; Non : Ouvrir la palette de couleur)" , #PB_MessageRequester_YesNo ) 
 If coulon<>6 
 trans\v = ColorRequester () 
 trans\v = RGB ( Blue (trans\v), Green (trans\v), Red (trans\v)) 
 EndIf 
 
 For ay=0 To picl_Y-2 
 
  For ax=0 To picl_X-1 
 
   If *pixel\v <> trans\v 
    sub = CreateRectRgn_(ax,picl_Y-ay-1,ax+1,picl_Y-ay-2) 
    CombineRgn_(main,main,sub,#RGN_OR) 
    DeleteObject_(sub) 
   EndIf 
 
   *pixel + 4 
 
  Next ax 
 
 Next ay 
 
 StopDrawing() 
 ProcedureReturn main 
 
EndProcedure 

File.s = OpenFileRequester("Open Bitmap","","Bitmap|*.bmp;*.png",0) 

If File 

 Image = LoadImage(1, File) 
 w = ImageWidth(1)
 h = ImageHeight(1) 
 ScreenX = GetSystemMetrics_(#SM_CXSCREEN) 
 ScreenY = GetSystemMetrics_(#SM_CYSCREEN) 
 HWnd = OpenWindow(0, screenx, screeny, w, h, "Mask-Image", #WS_POPUP) 
 Mask = CreateMask() 
 Oldsize = GetRegionData_(Mask, 0, 0) 
 *Source = AllocateMemory(Oldsize) 
 GetRegionData_(mask,oldsize,*Source) 
 *Target = AllocateMemory(Oldsize + 8) 
 Newsize = PackMemory(*Source,*Target,Oldsize,9) 
 Newfile.s = ReplaceString(File, GetExtensionPart(File),"png") 
 SaveImage(1, Newfile, #PB_ImagePlugin_PNG) 
 Rest = Newsize % 4 
 NomFenetre.s = Left(GetFilePart(File),Len(GetFilePart(File)) - 4)
 File = ReplaceString(ReplaceString(File, GetFilePart(File), GetFilePart(File)),GetExtensionPart(File),"pbi")
 
 If CreateFile(0, File) 
 
  WriteStringN(0,"UsePNGImageDecoder()")  
  WriteStringN(0,"") 
  WriteStringN(0,"Procedure OpenMaskedWindow_" + NomFenetre + "(WinID, x, y, Title.s, imID)") 
  WriteStringN(0,"") 
  WriteStringN(0," Hwnd" + NomFenetre + " = OpenWindow(winID, GetSystemMetrics_(#SM_CXSCREEN), y, " + Str(w) + ", " + Str(h) + ", Title, #WS_POPUP)") 
  WriteStringN(0," Memhandle = GlobalAlloc_(#GMEM_MOVEABLE," + Str(Oldsize + 8) + ")") 
  WriteStringN(0," *Mem = GlobalLock_(Memhandle)") 
  WriteStringN(0," UnpackMemory(?" + NomFenetre + "_Mask, *Mem)") 
  WriteStringN(0," Region = ExtCreateRegion_(0," + Str(Oldsize) + ", *Mem)") 
  WriteStringN(0," SetWindowRgn_(Hwnd" + NomFenetre + ", Region, #True)") 
  WriteStringN(0," Pic = CatchImage(imID,?" + NomFenetre +")") 
  WriteStringN(0," Brush = CreatePatternBrush_(Pic)") 
  WriteStringN(0," SetClassLong_(Hwnd" + NomFenetre + ", #GCL_HBRBACKGROUND, Brush)")  
  WriteStringN(0," ResizeWindow(WinID, x, y, #PB_Ignore, #PB_Ignore)") 
  WriteStringN(0," GlobalUnlock_(Memhandle)") 
  WriteStringN(0," GlobalFree_(Memhandle)") 
  WriteStringN(0," DeleteObject_(Region)") 
  WriteStringN(0," ProcedureReturn Hwnd" + NomFenetre) 
  WriteStringN(0,"") 
  WriteStringN(0," DataSection") 
  WriteStringN(0,"") 
  WriteStringN(0,"  " + Left(GetFilePart(File),Len(GetFilePart(File)) - 4)+":") 
  WriteStringN(0,"  ;***********") 
  WriteStringN(0,"") 
  WriteStringN(0,"  IncludeBinary " + Chr(34) + GetFilePart(Newfile) + Chr(34)) 
  WriteStringN(0,"") 
  WriteStringN(0,"  " + Left(GetFilePart(File),Len(GetFilePart(File)) - 4) + "_Mask:")
  WriteStringN(0,"  ;***********")  
  WriteStringN(0,"") 
  String.s = "  Data.l " 
 
  For i = 0 To Newsize - 4 - Rest Step 4 
  
   String + "$" + LSet(Hex(PeekL(*Target + i)),8," ") 
   Count + 1 
 
   If Count = 10 
    Count = 0 
    WriteStringN(0, String) 
    String = "  Data.l " 
   Else 
    String + "," 
   EndIf 
 
  Next i 
  
  If Count 
   String = Left(String, Len(String) - 1) 
   WriteStringN(0, String) 
  EndIf 
  
  WriteStringN(0,"") 
  WriteStringN(0," EndDataSection") 
  WriteStringN(0,"") 
  WriteStringN(0,"EndProcedure") 
  CloseFile(0) 
  MessageRequester("Fichier .pbi créé!","Cliquez droit pour sortir.",0) 
 
 Else 
 
  MessageRequester("Error!", "Can't create '"+ ReplaceString(ReplaceString(file, GetFilePart(file),"MaskWindow_" + GetFilePart(file)),GetExtensionPart(file),"pbi'"),0) 
 
 EndIf 

 SetWindowRgn_(hwnd, mask, #True) 
 ResizeWindow(0,(screenx - w) / 2,(screeny - h) / 2, #PB_Ignore, #PB_Ignore) 
 SetWindowCallback(@WindowCallback()) 
    
 Repeat 
 
  Select WaitWindowEvent() 
   Case #WM_LBUTTONDOWN 
    SendMessage_(hwnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0) 
   Case #WM_RBUTTONDOWN 
    Quit=1 
  EndSelect 
  
 Until Quit=1 
 
 DeleteObject_(mask) 
 
EndIf  

End

Re: What's changed for the DATA between v4.20 and 4.30 ??

Posted: Tue Nov 24, 2009 7:41 pm
by Denis
Ask to Fred on french forum :mrgreen:

Re: What's changed for the DATA between v4.20 and 4.30 ??

Posted: Tue Nov 24, 2009 9:15 pm
by rsts
Did you read the release notes?

cheers

Re: What's changed for the DATA between v4.20 and 4.30 ??

Posted: Wed Nov 25, 2009 8:41 am
by Kwai chang caine
Denis wrote:Ask to Fred on french forum :mrgreen:
I know that FRED is more on the french forum that before. 8)
But, i also know, that FRED is so much present on the official forum :roll:

It's the reason why i ask this question here :wink:

And i say to me...that perhaps somebody have the same problem that me, and can answer in some words at my problem :roll:
rsts wrote:Did you read the release notes?
So i not always all understand in the release note :oops:
I go to read in it....

I have just the hope, that somebody have the same problem, or perhaps a MASTER can see in several second the problem.
This code is very very great ..i use it since several years...
But ....i have not really understand it.
I have already modify it, to add the selector of color, and several other litle things, but i'm not enough strong for modify the "motor" :oops:

Thanks at you two for your answer 8)

Re: Please FRED, what's changed in this code between 4.20 & 4.30

Posted: Thu Nov 26, 2009 1:19 am
by yrreti
Kwaï chang caïne
I just modified your code quickly so it works in creating a pbi file of a selected png file with
4.40b7, but it's not complete (doesn't close program properly) and I just don't have the time to finish it
So perhaps when you fix that part, you could display the finished code here with an example of how to use it.

Code: Select all

; Creates a .pbi file in the directory of a bitmap, which should
; be used as skin/background for a window...
; The created .pbi file will contain the calculated window mask data
; as well include the converted bitmap (into .png format).
; Note: an example for using the created .pbi file can be found at
; "WindowSkin_Example.pb" !

; Modifié par KCC (Adaptation en 4.10 + Indentation de ce code et du code masque généré + Rajout des surlignages de label
; + Modification chemin du fichier dans le chemin de l'image) + Rajout du module de selection couleur de GILLOU


Procedure WindowCallBack(WindowId, Message, lParam, wParam)

If Message = #WM_PAINT
  StartDrawing(WindowOutput(0))
  DrawImage(ImageID(1), 0, 0)
  StopDrawing()
EndIf

ProcedureReturn #PB_ProcessPureBasicEvents

EndProcedure

UsePNGImageEncoder()
UsePNGImageDecoder()

Structure myBITMAPINFO
bmiHeader.BITMAPINFOHEADER
bmiColors.RGBQUAD[1]
EndStructure

Structure RGB
v.l
EndStructure

Procedure CreateMask()

hDC = StartDrawing(ImageOutput(1))
main  = CreateRectRgn_(0,0,0,0)
picl_X = ImageWidth(1)
picl_Y = ImageHeight(1)
mem = AllocateMemory(picl_X*picl_Y*4)
bmi.myBITMAPINFO
bmi\bmiHeader\biSize   = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth  = picl_X
bmi\bmiHeader\biHeight = picl_Y
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
GetDIBits_(hDC,ImageID(1),1,picl_Y-1,mem,bmi,#DIB_RGB_COLORS)
*pixel.RGB = mem
trans.RGB
trans\v = *pixel\v

If Blue (trans\v)=255 And Green (trans\v)=0 And Red (trans\v)=0 : messag$= " -> Red"
ElseIf Blue (trans\v)=0 And Green (trans\v)=255 And Red (trans\v)=0 : messag$= " -> Green"
ElseIf Blue (trans\v)=0 And Green (trans\v)=0 And Red (trans\v)=255 : messag$= " -> Blue"
ElseIf Blue (trans\v)=255 And Green (trans\v)=255 And Red (trans\v)=255 : messag$= " -> White"
ElseIf Blue (trans\v)=0 And Green (trans\v)=0 And Red (trans\v)=0 : messag$= " -> Black"
EndIf
coulon = MessageRequester ( "Selection of the color of the mask" , "Detected color : " + "Red : " + Str ( Blue (trans\v))+ " ; Green : " + Str ( Green (trans\v))+ " ; Blue : " + Str ( Red (trans\v))+messag$+ Chr (13)+ Chr (13)+ "You accept this color? (Yes : To use the color ; No : To open the pallet of color)" , #PB_MessageRequester_YesNo )
If coulon<>6
trans\v = ColorRequester ()
trans\v = RGB ( Blue (trans\v), Green (trans\v), Red (trans\v))
EndIf

For ay=0 To picl_Y-2

  For ax=0 To picl_X-1

   If *pixel\v <> trans\v
    sub = CreateRectRgn_(ax,picl_Y-ay-1,ax+1,picl_Y-ay-2)
    CombineRgn_(main,main,sub,#RGN_OR)
    DeleteObject_(sub)
   EndIf

   *pixel + 4

  Next ax

Next ay

StopDrawing()
ProcedureReturn main

EndProcedure

File.s = OpenFileRequester("Open Bitmap","","Bitmap|*.bmp;*.png",0)

If File

Image = LoadImage(1, File)
w = ImageWidth(1)
h = ImageHeight(1)
ScreenX = GetSystemMetrics_(#SM_CXSCREEN)
ScreenY = GetSystemMetrics_(#SM_CYSCREEN)
HWnd = OpenWindow(0, screenx, screeny, w, h, "Mask-Image", #WS_POPUP)
Mask = CreateMask()
Oldsize = GetRegionData_(Mask, 0, 0)
*Source = AllocateMemory(Oldsize)
GetRegionData_(mask,oldsize,*Source)
*Target = AllocateMemory(Oldsize + 8)
Newsize = PackMemory(*Source,*Target,Oldsize,9)
Newfile.s = ReplaceString(File, GetExtensionPart(File),"png")
SaveImage(1, Newfile, #PB_ImagePlugin_PNG)
Rest = Newsize % 4
NomFenetre.s = Left(GetFilePart(File),Len(GetFilePart(File)) - 4)
File = ReplaceString(ReplaceString(File, GetFilePart(File), GetFilePart(File)),GetExtensionPart(File),"pbi")

If CreateFile(0, File)

  WriteStringN(0,"UsePNGImageDecoder()") 
  WriteStringN(0,"")
  WriteStringN(0,"Procedure OpenMaskedWindow_" + NomFenetre + "(WinID, x, y, Title.s, imID)")
  WriteStringN(0,"")
  WriteStringN(0," Hwnd" + NomFenetre + " = OpenWindow(winID, GetSystemMetrics_(#SM_CXSCREEN), y, " + Str(w) + ", " + Str(h) + ", Title, #WS_POPUP)")
  WriteStringN(0," Memhandle = GlobalAlloc_(#GMEM_MOVEABLE," + Str(Oldsize + 8) + ")")
  WriteStringN(0," *Mem = GlobalLock_(Memhandle)")
  WriteStringN(0," UnpackMemory(?" + NomFenetre + "_Mask, *Mem)")
  WriteStringN(0," Region = ExtCreateRegion_(0," + Str(Oldsize) + ", *Mem)")
  WriteStringN(0," SetWindowRgn_(Hwnd" + NomFenetre + ", Region, #True)")
  WriteStringN(0," Pic = CatchImage(imID,?" + NomFenetre +")")
  WriteStringN(0," Brush = CreatePatternBrush_(Pic)")
  WriteStringN(0," SetClassLong_(Hwnd" + NomFenetre + ", #GCL_HBRBACKGROUND, Brush)") 
  WriteStringN(0," ResizeWindow(WinID, x, y, #PB_Ignore, #PB_Ignore)")
  WriteStringN(0," GlobalUnlock_(Memhandle)")
  WriteStringN(0," GlobalFree_(Memhandle)")
  WriteStringN(0," DeleteObject_(Region)")
  WriteStringN(0," ProcedureReturn Hwnd" + NomFenetre)
  WriteStringN(0,"")
  WriteStringN(0," DataSection")
  WriteStringN(0,"")
  WriteStringN(0,"  " + Left(GetFilePart(File),Len(GetFilePart(File)) - 4)+":")
  WriteStringN(0,"  ;***********")
  WriteStringN(0,"")
  WriteStringN(0,"  IncludeBinary " + Chr(34) + GetFilePart(Newfile) + Chr(34))
  WriteStringN(0,"")
  WriteStringN(0,"  " + Left(GetFilePart(File),Len(GetFilePart(File)) - 4) + "_Mask:")
  WriteStringN(0,"  ;***********") 
  WriteStringN(0,"")
  String.s = "  Data.l "

  For i = 0 To Newsize - 4 - Rest Step 4
 
   String + "$" + LSet(Hex(PeekL(*Target + i)),8," ")
   Count + 1

   If Count = 10
    Count = 0
    WriteStringN(0, String)
    String = "  Data.l "
   Else
    String + ","
   EndIf

  Next i
 
  If Count
   String = Left(String, Len(String) - 1)
   WriteStringN(0, String)
  EndIf
 
  WriteStringN(0,"")
  WriteStringN(0," EndDataSection")
  WriteStringN(0,"")
  WriteStringN(0,"EndProcedure")
  CloseFile(0)
  MessageRequester("File .pbi created!","Click right to leave.",0)

Else

  MessageRequester("Error!", "Can't create '"+ ReplaceString(ReplaceString(file, GetFilePart(file),"MaskWindow_" + GetFilePart(file)),GetExtensionPart(file),"pbi'"),0)

EndIf

SetWindowRgn_(hwnd, mask, #True)
;ResizeWindow(0,#PB_Ignore,#PB_Ignore,0,(screenx - w) / 2,(screeny - h) / 2, #PB_Ignore, #PB_Ignore)
;ResizeWindow(0,#PB_Ignore,#PB_Ignore,(screenx - w) / 2,(screeny - h) / 2, #PB_Ignore, #PB_Ignore)
ResizeWindow(0,#PB_Ignore,#PB_Ignore,(screenx - w) / 2,(screeny - h) / 2)
SetWindowCallback(@WindowCallback())
   
Repeat

  Select WaitWindowEvent()
   Case #WM_LBUTTONDOWN
    SendMessage_(hwnd,#WM_NCLBUTTONDOWN, #HTCAPTION,0)
   Case #WM_RBUTTONDOWN
    Quit=1
  EndSelect
 
Until Quit=1

DeleteObject_(mask)

EndIf 

End

Re: Please FRED, what's changed in this code between 4.20 & 4.30

Posted: Thu Nov 26, 2009 2:35 am
by netmaestro
You could try this, it does pretty much the same thing in a simpler and faster approach:

Code: Select all

ProcedureDLL GrabRegion(ImageID, transcolor) ; HBITMAP ImageID, COLORREF transcolor 

  ;=============================================== 
  ;                                              = 
  ;      Very fast bitmap -> region creator      = 
  ;      By netmaestro                           = 
  ;      Contributors: eesau, nico, flype        = 
  ;      June 26, 2007                           = 
  ;                                              =
  ;            ***  IMPORTANT  ***               =
  ;                                              =
  ;      transcolor must be in BGR format        = 
  ;                                              =
  ;=============================================== 
  
  Structure RECTARRAY
    rect.RECT[0] 
  EndStructure 

  GetObject_(ImageID, SizeOf(BITMAP), @bmp.BITMAP) 
  
  Protected width       = bmp\bmWidth 
  Protected height      = bmp\bmHeight 
  Protected hVisibleRgn = CreateRectRgn_(0, 0, width, height) 
  
  BmiInfo.BITMAPINFOHEADER 
  With BmiInfo 
    \biSize         = SizeOf(BITMAPINFOHEADER) 
    \biWidth        = width 
    \biHeight       = -height 
    \biPlanes       = 1 
    \biBitCount     = 32 
    \biCompression  = #BI_RGB 
  EndWith    
  
  rowbytes =  SizeOf(LONG)*width 

  *ColorBits = AllocateMemory(rowbytes*height) 
  
  hDC   = GetWindowDC_(#Null) 
  iRes  = GetDIBits_(hDC, ImageID, 0, height, *ColorBits, @bmiInfo, #DIB_RGB_COLORS) 
  ReleaseDC_(#Null, hDC) 
  
  Structure_Max=(width*height*16)+SizeOf(RGNDATAHEADER) 
  *Buffer.RGNDATAHEADER=AllocateMemory(Structure_Max) 
  *rd.RECTARRAY=*Buffer+SizeOf(RGNDATAHEADER) 

  rectcount = 0 
  For y=0 To height-1 
    pxcount=0 
    For x=0 To rowbytes-1 Step 4 
      *px.LONG = *ColorBits + rowbytes * y + x 
      If *px\l = transcolor  
        transcount = 1 : firsttrans = pxcount 
        x+SizeOf(LONG) : *px.LONG = *ColorBits + rowbytes * y + x 
        While *px\l = transcolor And x <= rowbytes-1
          transcount+1 : pxcount+1 : x+SizeOf(LONG) 
          *px = *ColorBits + rowbytes * y + x 
        Wend 
        x-SizeOf(LONG) : *px.LONG = *ColorBits + rowbytes * y + x 
        *rd\rect[rectcount]\left   = firsttrans            
        *rd\rect[rectcount]\top    = y                     
        *rd\rect[rectcount]\right  = firsttrans+transcount 
        *rd\rect[rectcount]\bottom = y+1      
        rectcount+1 
      EndIf 
      pxcount+1 
    Next 
  Next 
  
  With *Buffer 
    \dwSize         = SizeOf(RGNDATAHEADER) 
    \iType          = #RDH_RECTANGLES 
    \nCount         = rectcount 
    \nRgnSize       = rectcount * SizeOf(RECT) 
    \rcBound\left   = 0
    \rcBound\top    = 0
    \rcBound\right  = width
    \rcBound\bottom = height
  EndWith 
  
  RegionSize=SizeOf(RGNDATAHEADER)+(rectcount * SizeOf(RECT)) 
  hTransparentRgn = ExtCreateRegion_(0, RegionSize, *Buffer) 
  CombineRgn_(hVisibleRgn, hVisibleRgn, hTransparentRgn, #RGN_XOR) 
    
  FreeMemory(*Buffer) 
  FreeMemory(*ColorBits) 
  DeleteObject_(hTransparentRgn) 
  
  ProcedureReturn hVisibleRgn 
  
EndProcedure 

; Use your own image here, this is just for demo
CreateImage(0, 520,270)
StartDrawing(ImageOutput(0))
  Box(0,0,520,270,RGB(255,0,255))
  Ellipse(258,130,254,126,#Black)
  Ellipse(255,127,254,126,RGB(255,255,223))  
  DrawingMode(#PB_2DDrawing_Outlined)
  Ellipse(255,127,254,126,#Black)
StopDrawing()

; Simple code to use bitmap & region for skinned window
hBrush = CreatePatternBrush_(ImageID(0))
OpenWindow(0,0,0,ImageWidth(0),ImageHeight(0),"",#PB_Window_BorderLess|#PB_Window_ScreenCentered|#PB_Window_Invisible)
SetClassLongPtr_(WindowID(0),#GCL_HBRBACKGROUND, hBrush)
SetWindowRgn_(WindowID(0), GrabRegion(ImageID(0),RGB(255,0,255)),#True)
CreatePopupMenu(0)
MenuItem(9, "Exit")
HideWindow(0,0)

quit=0
Repeat:
  EventID = WaitWindowEvent()
  Select EventID
    Case #WM_LBUTTONDOWN
      SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
    Case #WM_RBUTTONUP
      DisplayPopupMenu(0,WindowID(0))
    Case #PB_Event_CloseWindow
      quit=1
    Case #PB_Event_Menu
      If EventMenu()=9 : quit=1 : EndIf
  EndSelect
Until quit

DeleteObject_(hBrush)

Re: Please FRED, what's changed in this code between 4.20 & 4.30

Posted: Thu Nov 26, 2009 9:48 am
by Kwai chang caine
Very very thanks at you two
You save my life 8)
Image

Because this code is the most important code for me since several years.
It's even, one of the reason why, i have choose PureBasic, there are 4 years.

Yes, when i have see, what MISCHA do with a windows :shock:
At this moment only gray square windows exist :(
Or perhaps with several colors......but when i have clic run and see this windows with the form of a picture...i was like a baby with his feeding bottle :D

At this time, VB6 don't do this :cry:
Now i have find a code in VB6 for skin windows like PB.
But PB is the best.

Again thanks for your great present.
Because this code is too hard for the level zero of poor KCC :oops:

Yesterday, i have believe that nobody can help KCC :(
And this morning i have this great surprise
Image
KCC is happy because only a MASTER can modify it, and two MASTERS, it's more than i have dreaming
You are really great mans 8) ..and i'm proud to know you.... and this great language obviously.
PureBasic is a great language....but you are also a part of the power of PB :wink:

Like magician....you create code....who change my PC
And the most funny...it's you use the same words that KCC...
But when KCC use this words..the PC shutdown ..or KCC have a "Boing" and a red line :?

After four years of programming with you the masters and learn all the days...KCC ask a question at itself...perhaps the order of the words is important ??? :roll: :lol:

Again thanks, i wish you a very very good day
Your servant KCC

Re: What's changed in this code between 4.20 & 4.30 [Resolved]

Posted: Thu Nov 26, 2009 10:28 am
by Kwai chang caine
Like usually the code of NETMAESTRO is perfect.
Even KCC can use it :shock: it's a sign of perfection, no ???? :lol:
Thanks again :wink:

But i try the code of YRETTI, and the window don't appear :shock:
She appears in the taskbar only :(
Probably KCC forget something :roll:

I have tried to add a

Code: Select all

HideWindow(0, #False)
We never know...with a litle bit of chance :lol: :lol:

But the chance is not the better quality in programming :oops: