Page 2 of 3

Posted: Wed Jun 13, 2007 2:20 am
by r_hyde
DARKGirl
Try this out:

Code: Select all

Procedure MyWindowCallback(hWnd, message, wParam, lParam) 
  Select message 
    Case #WM_RBUTTONUP
      Debug "right button up!"
  EndSelect 
  
  Result = DefWindowProc_(hWnd, message, wParam, lParam)
  ProcedureReturn Result 
EndProcedure 

PV.WNDCLASSEX ;PV = PropertyViewer 
PVClass.s = "PViewer" 


PV\cbSize = SizeOf(PV) 
PV\style = #CS_HREDRAW | #CS_VREDRAW 
PV\lpfnWndProc = @MyWindowCallback() 
PV\cbClsExtra = 0 
PV\cbWndExtra = 0 
PV\hInstance = hInstance 
PV\hIcon = LoadIcon_(NULL, IDI_APPLICATION) 
PV\hCursor = LoadCursor_(NULL, IDC_ARROW) 
PV\hbrBackground = GetStockObject_( #WHITE_BRUSH) 
PV\lpszMenuName = 0 
PV\lpszClassName = @PVClass 
PV\hIconSm = 0 

RegisterClassEx_(@PV) 
hwnd = CreateWindowEx_(0, "PViewer", "sample", #WS_OVERLAPPEDWINDOW, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #CW_USEDEFAULT, #Null, #Null, GetModuleHandle_(0), #Null) 
ShowWindow_(hwnd, 1) 
;UpdateWindow_(hwnd) 

ret.b = GetMessage_(@msg, hwnd, 0, 0 )
While msg <> 0
  If ret = -1
    Debug "error!"
  Else
    TranslateMessage_(@msg)
    DispatchMessage_(@msg)
  EndIf
  ret = GetMessage_(@msg, hwnd, 0, 0 )
Wend
(I switched to CreateWindowEx_() because I'm more used to it

Posted: Wed Jun 13, 2007 6:17 am
by DARKGirl
omg I fixed my own code!


r_hyde: huh, I didnt even know you posted a comment. I have managed to successfully register my very own class and create a window and attach it to a parent window. I gave it a general #WS_EX_Clientedge so I know theres something there

Posted: Thu Jun 14, 2007 5:19 am
by DARKGirl
here's what I have so far:

Code: Select all


Structure General
  hwnd.l
  GadgetID.l
  Positon.l
  PropertyName.s
  ToolTip.s
  state.b ;Is this field enabled or Disabled?
EndStructure

Structure TextField
  Common.General
  String.s
  type.l ;Theres Numerical, General, Password
EndStructure

Structure CheckBoxField
  Common.General
  CheckBoxState.b
EndStructure
  
Structure ColorPickerField
  Common.General
  Color.l ;This is the color value that is saved when the user chooses the color in the color picker.
 
EndStructure

Structure LinkedListStructure
  String.s
  Position.l
EndStructure

Global NewList PropertyGrid.LinkedListStructure()

Structure ComboBox
  Common.General
Propertygrid.l
EndStructure


TotalPropertyGrids.l
TotalPropertyFields.l

Procedure PropertyGridGadget(Gadget, x, y, Width, Height)
  
EndProcedure

Procedure AddBooleanField(PropertyName.s, Value.b, Position.b)
  
EndProcedure

Procedure AddColorPickerField(PropertyName.s, Value.b, Position.b)
  
EndProcedure
  
Procedure AddComboBoxField(PropertyName.s, Value.b, Position.b)
  
EndProcedure 

Procedure AddSpinField(PropertyName.s, MinValue.l, MaxValue.l, Position.b)
  
EndProcedure

Procedure AddTextField(PropertyName.s, Text.s, Position.b)
  
EndProcedure

Procedure AddCheckBoxFleild(PropertyName.s, state.b, Position.b)
  
EndProcedure

Procedure OpenPropertyGroup(GroupName.s)
  
EndProcedure

Procedure ClosePropertyGroup()
  
EndProcedure

Procedure GetPropertyFieldState(Position.b)
  
EndProcedure

Procedure SetPropertyFieldState(Position.b)
  
EndProcedure

Procedure GetPropertyFieldText(Position.b)
  
EndProcedure

Procedure SetPropertyFieldText(Position.b)
  
EndProcedure

Procedure OpenPropertyGroupFieldList(Gadget)
  
EndProcedure

Procedure ClosePropertyGroupFieldList(Gadget)
  
EndProcedure


Procedure PVCallback(hwnd, message, wParam, lParam)
  Select message
    
    Case #WM_NCCREATE
      
    Case #WM_NCDESTROY
      
    Case #WM_ERASEBKGND
      ProcedureReturn 1
      
    Case #WM_LBUTTONDOWN
      
    Case #WM_RBUTTONDOWN
      
    Case #WM_SETFONT
      
    Case #WM_PAINT 
      
      
  EndSelect
   
  Debug message 
  ProcedureReturn DefWindowProc_(hwnd, message, wParam, lParam)
EndProcedure
I sort of need some help setting up all the structures and whatnot because its all confusing to me. Any help is appreciated

Posted: Thu Jun 14, 2007 9:33 pm
by Fluid Byte
DARKGirl, I'm currently working on a PropertyViewer just like the one you are requesting. It's almost done, but it lacks proper scrolling. It's not based on any existing controls, so completey written from scratch. "Unfortuneatly" I'm flying to spain tomorrow for 10 days and will not be able to finish it. But when I'm back I will post the whole source in the forum.

Laters! 8)

Posted: Fri Jun 15, 2007 2:47 am
by DARKGirl
Hey well thats cool. My goal is to have my control mimic the .Net control.

Posted: Fri Jun 15, 2007 12:19 pm
by milan1612
I'm looking forward... :wink:

Posted: Sat Jun 16, 2007 4:29 am
by DARKGirl
ok, I have some good news, the more and more I work on this project, the more and more I understand it. I would like this control to work with many of the existing PB functions, as I have said before.

How do I get it to work with CreateGadgetList()? I assume this sets some sort of variable for the Parent hwnd of the CreateWindowEx function. If I cannot get it to work with CreateGadgetList, I will just have to require the user to pass the parent window hwnd to the function, so the gadget will appear on the correct window!

I also had a slight problem with dynamically creating linked lists, because they are a MUST because you should be able to use this function to create as many PropertyGrid Gadgets as you want! I don't think people will be too happy if they can only create one per application...

Thanks to the code I found here: http://www.purebasic.fr/english/viewtop ... sc&start=0, it looks like I just might be able to do this. I haven't created the window drawing code yet, I am still working on the multiple instance of the control part. Remember when I say 'instance' I don't mean some crazy OOP nonsense. I only mean 'the ability to create multiple controls within an application'.

Posted: Sat Jun 16, 2007 6:25 am
by hallodri
You can get the current window with PB_Object_GetThreadMemory.

Example :

Code: Select all

Structure PB_GadgetGlobals
  CurrentWindow.l
  ;[...]
EndStructure 

Import "Gadget.lib"
  PB_Object_GetThreadMemory(Globals)
  PB_Gadget_Globals
EndImport

Procedure StaticGadget(x.l,y.l,w.l,h.l,flags.l=0)
  Protected hWnd 
  Protected *Globals.PB_GadgetGlobals
  
  *Globals   = PB_Object_GetThreadMemory(PB_Gadget_Globals) 
  hWnd       = CreateWindowEx_(#WS_EX_STATICEDGE,"static","",#WS_CHILD|#WS_VISIBLE|flags,x,y,w,h,*Globals\CurrentWindow,0,0,0)
  
  ProcedureReturn hWnd
EndProcedure
  
  
hWnd = OpenWindow(0,#PB_Ignore,#PB_Ignore,200,200,"leer",#WS_OVERLAPPEDWINDOW)


CreateGadgetList(hWnd)
StaticGadget(10,10,100,100)

Repeat
	event = WaitWindowEvent()

Until event = #PB_Event_CloseWindow  

For more info see in PB sdk directory.

Posted: Sat Jun 16, 2007 6:40 am
by DARKGirl
Blah, that is a bit too confusing for me, I think I will just keep it simple and require the user to pass the window they want it to be added to.

My second question, is that how do I throw a compiler exception when the user tries to create a gadget with an existing gadget ID? Sure I can scratch something together and make a messagebox popup, and end the application, but that would be no fun.

My Third Question, what would be the best way to draw to a window? I am ready to write the code for the #WM_Paint message, but not sure of the 'proper' way to do it.

Posted: Wed Aug 15, 2007 1:21 pm
by milan1612
Any news?

Posted: Wed Aug 15, 2007 1:27 pm
by Fluid Byte
Hehe, I dropped the project because of other things I had to do. But it's almost done. I try to finish my version soon and post it here. Maybe over the weekend.

Posted: Wed Aug 15, 2007 1:54 pm
by milan1612
Now you made me impatient :twisted:
No, I'm really looking forward...

Posted: Wed Aug 15, 2007 2:11 pm
by Fluid Byte
Oh noooz! Pressure! :shock:

PS: Seriously, I finish this! :D :roll:

Posted: Wed Sep 26, 2007 2:14 pm
by DoubleDutch
Fluid Byte: Any luck with this yet?

Posted: Wed Sep 26, 2007 3:33 pm
by Fluid Byte
Ok, enuff excuses... :roll:

I'll sit on my butt today! :!: