API RoundRect function

Just starting out? Need help? Post your questions and find answers here.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

API RoundRect function

Post by Num3 »

What's wrong with my code!

It simply does not draw a rounded rectangle....

Grrrrrrrrr :evil:

Code: Select all

dc.l=OpenWindow(0,10,10,600,400,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"teste")
If dc
  
  Debug roundrect_(dc,50, 50, 250, 150, 50, 50)
  
  Repeat
    Event=WaitWindowEvent()
  Until Event=#PB_EventCloseWindow
  
EndIf
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Code: Select all

OpenWindow(0,10,10,600,400,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"teste") 
hwnd=WindowID()
hdc=GetDC_(hwnd)
roundrect_(hdc,50, 50, 250, 150, 50, 50) 
  
Repeat 
  Event=WaitWindowEvent() 
Until Event=#PB_EventCloseWindow 
OpenWindow doesn't return the hdc handle.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

I'm so stupid....

Too much time looking at VB code :P


BTW:

Anyone knows how to make these kind of artifacts not get destroyed when you overlap another window !??!?!?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I think there's an event that tell you when there's a need of redrawing but I can't remember which one :oops:
Sparkie, we need your help :wink:
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Ehehehe

I'm just trying to make Firefox like Frame3DGadgets (rounded corners)
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

This isn't my strong area but this seems to work. Maybe someone with more knowledge will improve on it. ;)

Code: Select all

Procedure myCallback(hwnd, msg, wparam, lparam)
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_PAINT
      hdc = BeginPaint_(hwnd, @ps.PAINTSTRUCT)
      RoundRect_(hdc,50, 50, 250, 150, 50, 50) 
      EndPaint_(hwnd,@ps)
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow(0,10,10,600,400,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget,"teste") 
SetWindowCallback(@myCallback())
UpdateWindow_(WindowID())
  
Repeat 
  event=WaitWindowEvent() 
Until event=#PB_EventCloseWindow 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

Another one:

Code: Select all

Procedure RoundRect(DC,x,y,x1,y1,Rim,RimRGB,BkRGB,angle1,angle2) 
 If Rim=0:RimRGB=BkRGB:EndIf
     Pen=CreatePen_( #ps_insideframe,Rim,RimRGB)            
     brush = CreateSolidBrush_(BkRGB ) 
     SelectObject_(DC,pen) 
     SelectObject_(DC,brush)   
     RoundRect_(DC,x,y,x1,y1,angle1,angle2)   
     DeleteObject_(pen)
     DeleteObject_(brush)
EndProcedure
 
 hWnd = OpenWindow(0,0,0,0,0 , #WS_OVERLAPPEDWINDOW | #WS_MAXIMIZE,"")  
 hDC = GetDC_(hWnd)  
 RoundRect(hdc,100,100,400,300,4,#blue,RGB(230,230,255) ,20,20)
 Repeat 
 Until WaitWindowEvent()= #PB_Event_CloseWindow 
 
Post Reply