SplitterGadget SetGadgetState API

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5499
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

SplitterGadget SetGadgetState API

Post by Kwai chang caine »

Hello at all

Someone know what API SetGadgetState use for replace it ?

Code: Select all

OpenWindow(0, 0, 0, 240, 230, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Bouton1    = 0 
#Bouton2    = 1
#Separateur = 2
  
ButtonGadget(#Bouton1, 0, 0, 0, 0, "Bouton 1") ; Inutile de préciser la taille ou les coordonnées
ButtonGadget(#Bouton2, 0, 0, 0, 0, "Bouton 2") ; car elles seront déterminées automatiquement
SplitterGadget(#Separateur, 5, 5, 230, 130, #Bouton1, #Bouton2, #PB_Splitter_Separator|#PB_Splitter_Vertical)
UpdateWindow_(GadgetID(#Separateur))

For i = 1 To 200 Step 20

 SetGadgetState(#Separateur, i) ; <==== Replace it by an API

 UpdateWindow_(GadgetID(#Separateur))
 Delay(300)

Next
Have a good day
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget SetGadgetState API

Post by RASHAD »

Hi KCC
Why?

Code: Select all

For i = 1 To 200 Step 20

 ;SetGadgetState(#Separateur, i) ; <==== Replace it by an API
 MoveWindow_(GadgetID(#Bouton1),5,6,i,130,1)
 MoveWindow_(GadgetID(#Bouton2),5+i,6,230-i,130,1)

 UpdateWindow_(GadgetID(#Separateur))
 Delay(300)

Next

Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5499
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: SplitterGadget SetGadgetState API

Post by Kwai chang caine »

Hello my friend RASHAD
There are too much time, i'm so happy to read you :D mainly me.. :oops: i'm not sure it's the case for you :mrgreen: :lol:

Thanks for your code, but unfortunately it's not exactely that what i want to do :oops:
You have changing the size of buttons, and me i want give the order to the splitter to move his separator :|
Finally EXACTELY the API that FRED use for his SetGadgetState() :idea:
Pyramidal MASTER wrote:Why?
I have asking help in this other thread, for try to forcing the left local explorer file in FileZilla to hide, but nobody can really help me :|

viewtopic.php?p=630475#p630475

So i say to me : "i continue to search by myself, if i can terminate my cow pat code :idea: "

I have already found the Hwnd of the local explorer file that i want to hide 8)
Now I still have to found wich SplitterGadget i must to send the order to move the separator of zero left...
But the worst in all that, it's i'm not able to talk his language when i will meet him :lol:
Now thanks to you, perhaps that with MoveWindow_() he will obey me like a doggie :mrgreen:

Again thanks for your precious help and have a very good day
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget SetGadgetState API

Post by RASHAD »

Hi KCC
I think this is what Fred is using except there should be a resizable window representing the splitter itself
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5499
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: SplitterGadget SetGadgetState API

Post by Kwai chang caine »

Ahhh ok !!!
I thought the splitter gadget was a real container gadget with a line separator in the middle and that you could position this separator with an API :oops:
Thanks for your explanation
Have a good day
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget SetGadgetState API

Post by RASHAD »

Hi KCC
You was interested in C & C++ right ?
Have fun :D

Code: Select all

#include    <windows.h>

#define     MINSIZE        50 // The minimal width And height a childwindow should have
#define     SBS            2  // Short For SplitterBarSize

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   Static   HWND           hwndChild1, hwndChild2, hwndChild3;
   Static   CREATESTRUCT   *cs;
   Static   HCURSOR        hcSizeNS, hcSizeEW, hcArrow;
   Static   int            xDiv, yDiv;
   Static   BOOL           xSizing, ySizing;

   int                     xPos, yPos;
   RECT                    rect, focusrect;
   HDC                     hdc;

   switch(iMsg)
   {
   Case WM_CREATE :
      cs = (CREATESTRUCT *)lParam;
      xDiv = 300;
      yDiv = 300;

      hwndChild1 = CreateWindowEx(WS_EX_CLIENTEDGE, "Pane 1", "Child 1",
                     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
                     0, 0, 0, 0, hwnd, NULL, cs->hInstance, NULL);
      hwndChild2 = CreateWindowEx(WS_EX_CLIENTEDGE, "Pane 2", "Child 2",
                     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
                     0, 0, 0, 0, hwnd, NULL, cs->hInstance, NULL);
      hwndChild3 = CreateWindowEx(WS_EX_CLIENTEDGE, "Pane 3", "Child 3",
                     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
                     0, 0, 0, 0, hwnd, NULL, cs->hInstance, NULL);

      hcSizeNS = LoadCursor(NULL, IDC_SIZENS);
      hcSizeEW = LoadCursor(NULL, IDC_SIZEWE);
      hcArrow  = LoadCursor(NULL, IDC_ARROW);
      Break;

   Case WM_SIZE :
      GetClientRect(hwnd, &rect);
      // Make sure splitterbars are visible
      If(xDiv > rect.right - MINSIZE)
      {
         xDiv = rect.right - MINSIZE;
      }
      Else If(xDiv < MINSIZE)
      {
         xDiv = MINSIZE;
      }
      If(yDiv > rect.bottom - MINSIZE)
      {
         yDiv = rect.bottom - MINSIZE;
      }
      Else If(yDiv < MINSIZE)
      {
         yDiv = MINSIZE;
      }
      MoveWindow(hwndChild1, rect.left, rect.top + 1,
                  rect.left + xDiv - SBS, rect.top + yDiv - SBS, FALSE);
      MoveWindow(hwndChild2, rect.left + xDiv + SBS,
                  rect.top + 1, rect.right - rect.left - xDiv - SBS, rect.top + yDiv - SBS, FALSE);
      MoveWindow(hwndChild3, rect.left, rect.top + yDiv + SBS,
                  rect.right - rect.left, rect.bottom - rect. top - yDiv - SBS, FALSE);
      InvalidateRect(hwnd, &rect, TRUE);
      Break;

   Case WM_LBUTTONDOWN :
      xPos = (int)LOWORD(lParam);
      yPos = (int)HIWORD(lParam);

      xSizing = (xPos > xDiv - SBS && xPos < xDiv + SBS);
      ySizing = (yPos > yDiv - SBS && yPos < yDiv + SBS);

      If(xSizing || ySizing)
      {
         SetCapture(hwnd); // Track movement of the mousepointer
         If(xSizing)
         {
            SetCursor(hcSizeEW);
         }
         Else If(ySizing)
         {
            SetCursor(hcSizeNS);
         }
      }
      Break;

   Case WM_LBUTTONUP :
      If(xSizing || ySizing)
      {
         ReleaseCapture();
         hdc = GetDC(hwnd);
         GetClientRect(hwnd, &rect);
         If(xSizing)
         {
            SetRect(&focusrect, xDiv - SBS, rect.top, xDiv + SBS, yDiv);
            DrawFocusRect(hdc, &focusrect);
            xSizing = FALSE;
         }
         If(ySizing)
         {
            SetRect(&focusrect, rect.left + 1, yDiv - SBS, rect.right, yDiv + SBS);
            DrawFocusRect(hdc, &focusrect);
            ySizing = FALSE;
         }
         ReleaseDC(hwnd, hdc);
      }
      // Post a size message so the childwindows get their new size
      PostMessage(hwnd, WM_SIZE, 0, 0);
      Break;

   Case WM_MOUSEMOVE :
      xPos = (int)LOWORD(lParam);
      yPos = (int)HIWORD(lParam);

      If(wParam == MK_LBUTTON)   // Is one of the splitterbars being moved?
      {
         If(xSizing || ySizing)
         {
            hdc = GetDC(hwnd);
            GetClientRect(hwnd, &rect);

            If(xSizing)
            {
               SetRect(&focusrect, xDiv - SBS, rect.top, xDiv + SBS, yDiv);
               DrawFocusRect(hdc, &focusrect);

               xDiv = xPos;

               SetRect(&focusrect, xDiv - SBS, rect.top, xDiv + SBS, yDiv);
               DrawFocusRect(hdc, &focusrect);
            }
            If(ySizing)
            {
               SetRect(&focusrect, rect.left + 1, yDiv - SBS, rect.right, yDiv + SBS);
               DrawFocusRect(hdc, &focusrect);

               yDiv = yPos;

               SetRect(&focusrect, rect.left + 1, yDiv - SBS, rect.right, yDiv + SBS);
               DrawFocusRect(hdc, &focusrect);
            }
            ReleaseDC(hwnd, hdc);
         }
         Break;   // Leave
      }

      If( (xPos > xDiv - SBS && xPos < xDiv + SBS) && GetCursor() != hcSizeEW )
      {
         SetCursor(hcSizeEW); // hovering above the vertical splitterbar
      }
      Else If( (yPos > yDiv - SBS && yPos < yDiv + SBS) && GetCursor() != hcSizeNS )
      {
         SetCursor(hcSizeNS); // hovering above the horizontal splitterbar
      }
      Else If(GetCursor() != hcArrow)
      {
         SetCursor(hcArrow);  // not hovering above a splitterbar
      }
      Break;

   Case WM_CLOSE :
      DestroyWindow(hwnd);
      Break;

   Case WM_DESTROY :
      PostQuitMessage(0);
      Break;
   }
   Return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

LRESULT CALLBACK Child1WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   switch(iMsg)
   {
   Case WM_CREATE :
      Break;
   }
   Return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

LRESULT CALLBACK Child2WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   switch(iMsg)
   {
   Case WM_CREATE :
      Break;
   }
   Return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

LRESULT CALLBACK Child3WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
   switch(iMsg)
   {
   Case WM_CREATE :
      Break;
   }
   Return DefWindowProc(hwnd, iMsg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
   HWND        hwnd;
   MSG         msg;
   WNDCLASS    wndclass;
   char        szAppName[] = "SplitterApp";

   wndclass.style         = 0;
   wndclass.lpfnWndProc   = WndProc;
   wndclass.cbClsExtra    = 0;
   wndclass.cbWndExtra    = 0;
   wndclass.hInstance     = hInstance;
   wndclass.hIcon         = LoadIcon(hInstance, szAppName);
   wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
   wndclass.lpszMenuName  = szAppName;
   wndclass.lpszClassName = szAppName;
   RegisterClass(&wndclass);

   wndclass.lpfnWndProc   = Child1WndProc;
   wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
   wndclass.lpszClassName = "Pane 1";
   RegisterClass(&wndclass);

   wndclass.lpfnWndProc   = Child2WndProc;
   wndclass.lpszClassName = "Pane 2";
   RegisterClass(&wndclass);

   wndclass.lpfnWndProc   = Child3WndProc;
   wndclass.lpszClassName = "Pane 3";
   RegisterClass(&wndclass);

   hwnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW | SW_MAXIMIZE | WS_VISIBLE,
                        0, 0, 600, 500, NULL, NULL, hInstance, szCmdLine);

   While (GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   Return (int)msg.wParam;
}
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5499
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: SplitterGadget SetGadgetState API

Post by Kwai chang caine »

You was interested in C & C++ right ?
Yes !!!! it's my dream...like the Assembly 8)
But i understand nothing :oops: :lol:
The worst part... is that I don't even know how to compile a code in C :mrgreen:

But it's when even interesting...that can give to me a begining of idea
Thanks a lot RASHAD 8)
ImageThe happiness is a road...
Not a destination
Post Reply