Author Topic: tabControl & TCN_SELCHANGE  (Read 12326 times)

0 Members and 2 Guests are viewing this topic.

Aurel

  • Guest
tabControl & TCN_SELCHANGE
« on: October 16, 2013, 02:42:53 PM »
charles
it looks to me that oxygen don't like to select negative values under
CASE block like this:
Code: [Select]
  'get file from clicked tab  -> not work
     CASE tcID
If notifycode= TCN_SELCHANGING then
   'autoSave()
       print "change selected"
   'FindTab()
End If

is this bug or simply not work on this way but it is weird because
this work:
Code: [Select]
'doubleClick listbox item -> jump to line
IF notifycode = LBN_DBLCLICK
'pos=GETSELECTED(w1,3)
         pos = SendMessage Lbox,LB_GETCURSEL,0,0
         
For n=0 TO pos
IF pos = n
fnpos=LBitems[pos]
SetFocus hsci
SendMessage hsci,SCI_GOTOLINE,fnpos,0
END IF
Next n
pos=0
END IF

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #1 on: October 17, 2013, 12:29:17 AM »
May be a problem elsewhere:

Test code:
Code: [Select]
%abc -2
sys a=-2
select a
case abc
print -2
end select

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #2 on: October 17, 2013, 12:37:37 AM »
Charles
It looks that compiler sometimes need in
IF .... THEN
END IF

and sometimes work without THEN properly  ???
by the way compiler complain about keyword END...
like END is not recognized like END IF pair...right?

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #3 on: October 17, 2013, 01:00:27 AM »
There is no problem at all i will post here complete code of ASciEdit
in which is this problem with TCN_SELCHANGE...
simply because of some reason tab switching is not detected...
maybe someone else figure what is ?


.

Frankolinox

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #4 on: October 17, 2013, 07:02:29 AM »
so far I suppose it's a simple programming mistake you've made, aurel.
this example works for me (first charles, second frank)

Code: [Select]
%TCN_FIRST               = 0-550       
%TCN_LAST                = 0-580

%TCN_SELCHANGE   = %TCN_FIRST - 1
%TCN_SELCHANGING = %TCN_FIRST - 2

%abc -2
sys a=-2
select a
case abc
print -2
end select


sys notifycode,tcID
tcID=1
select tcID
case tcID

        If notifycode= %TCN_SELCHANGING then
           'autoSave()
       print "change selected"
           'FindTab()                   
        End If
end select
print tcID
print %TCN_SELCHANGING '-552 ok :)
print "ok"

regards, frank

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #5 on: October 17, 2013, 10:01:34 AM »
Hi Frank and thanks..
it is not programming mistake but is is differnt version of constant
%TCN_FIRST               = 0-550     
%TCN_SELCHANGE   = %TCN_FIRST - 1

i use
TCN_SELCHANGE = -551
and in my case program not detect this notification message  ???
ok i will do on your way ... ;)

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #6 on: October 17, 2013, 12:26:35 PM »
Frank...
do you test this inside callback function?
Not work ...and why not ...looks like mistery ::)

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #7 on: October 18, 2013, 01:19:43 AM »
i still don't get it why not work like in some other languages
in attachment is version which get something but not work properly...

.

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #8 on: October 18, 2013, 11:20:29 AM »

Oxygen Cases expect simple numbers

So expressions like 0-551 will not work

Code: [Select]
% A 0-551
sys c=-551
select c
case A  'problem when expanded to 0-1
print -551
end select

I will see if it is easy to fix.

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #9 on: October 18, 2013, 12:25:34 PM »
sorry Charles if i bothering you with this
but when you say simple number
this constant can be  -551
not neccecery  0-550  or -550-1 like i see in some languages
i think that oxygen don't see negative number.

I don't know if this method work in FreeBasic but i will check...

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #10 on: October 18, 2013, 01:31:32 PM »
i search complete Freebasic forum in hope that i will find any
simple tabControl example and i can't found anything... ::)
how is that possible  ???
i will try on german forum.. ::)

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #11 on: October 18, 2013, 02:07:46 PM »
Negative number equates: no problem, we use many of them.

The problem is that Cases do not understand expressions, only numbers or ascii characters.

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #12 on: October 18, 2013, 02:15:49 PM »
charles
as i say there is no need for 0-550
TCN_SELCHANGE is  -551
ok

but i think that is problem in notification message.
Eros give me thinBasic example but nothing..
also i have found C example but i don't know how to properly translate this code to
oxygen...here is ..
Code: [Select]
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
 
HWND hwndMain;
HWND hwndTab;
HWND hwnd0;
HWND hwnd1;
HWND hwnd2;
HWND hwnd3;
HINSTANCE hinst;
 
LRESULT CALLBACK ChildrenProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
 
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}
 
 
void CloseWindows()
{
    DestroyWindow( hwnd0 );
    DestroyWindow( hwnd1 );
    DestroyWindow( hwnd2 );
    DestroyWindow( hwnd3 );
}
 
void MakeWindow(int num)
{
    if(num==0)
    {
        hwnd0=CreateWindowEx(0,
                "TabChild",
                "",
                WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS,
                0, 0,
                300, 300,
                hwndMain,
                NULL,
                hinst,
                NULL);
 
        HWND hwnd01=CreateWindow(
                    "EDIT",
                    "Just",
                    WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER,
                    0, 50, 100, 25,
                    hwnd0,
                    NULL,
                    hinst,
                    NULL);
 
        SetWindowPos(hwnd0,HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
        SetWindowPos(hwnd01,HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
    }
}
 
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        case WM_NOTIFY:
            switch (((LPNMHDR)lParam)->code)
            {
            case TCN_SELCHANGE:
                {
                    int iPage = TabCtrl_GetCurSel(hwndTab);
                    CloseWindows();
                    if(iPage == 0)
                        MakeWindow(0);
                    if(iPage == 1)
                        MakeWindow(1);
                    if(iPage == 2)
                        MakeWindow(2);
                    if(iPage == 3)
                        MakeWindow(3);
                    break;
                }
            }
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}
 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;
    hinst=hInstance;
 
 
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = "myWindowClass";
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
 
    RegisterClassEx(&wc);
 
 
    hwndMain = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        "myWindowClass",
        "The title of my window",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 350, 300,
        NULL, NULL, hInstance, NULL);
 
 
 
    ShowWindow(hwndMain, nCmdShow);
    UpdateWindow(hwndMain);
    InitCommonControls();
    hwndTab=CreateWindowEx(0,
                "SysTabControl32",
                "",
                WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,
                0, 0,
                300, 250,
                hwndMain,
                NULL,
                hInstance,
                NULL);
 
    TCITEM tie;
    tie.mask = TCIF_TEXT;
    tie.pszText = "Hi1";
    TabCtrl_InsertItem(hwndTab, 0, &tie);
 
    tie.mask = TCIF_TEXT;
    tie.pszText = "Hi2";
    TabCtrl_InsertItem(hwndTab, 1, &tie);
 
    tie.mask = TCIF_TEXT;
    tie.pszText = "Hi3";
    TabCtrl_InsertItem(hwndTab, 2, &tie);
 
    tie.mask = TCIF_TEXT;
    tie.pszText = "Hi4";
    TabCtrl_InsertItem(hwndTab, 3, &tie);
 
    TabCtrl_SetCurSel(hwndTab, 1);
    ShowWindow(hwndTab, SW_SHOW);
    UpdateWindow(hwndTab);
 
    WNDCLASSEX wcx;
    wcx.cbSize        = sizeof(WNDCLASSEX);
    wcx.style         = 0;
    wcx.lpfnWndProc   = ChildrenProc;
    wcx.cbClsExtra    = 0;
    wcx.cbWndExtra    = 0;
    wcx.hInstance     = hInstance;
    wcx.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wcx.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wcx.lpszMenuName  = NULL;
    wcx.lpszClassName = "TabChild";
    wcx.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
 
    RegisterClassEx(&wcx);
 
    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}
 

in DLib structure viewer i have found that NMHDR is this

Type NMHDR
      hwndFrom as INT
      idFrom   as INT
      code     as INT
  End Type


what you think?

kryton9

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #13 on: October 18, 2013, 10:17:28 PM »
Aurel what part do you need translating, I don't have time to make that whole thing work, but I could help with a certain part.

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #14 on: October 18, 2013, 10:25:05 PM »
hi kent..
rhis one :
Code: [Select]
case WM_NOTIFY:
            switch (((LPNMHDR)lParam)->code)
            {
            case TCN_SELCHANGE:

as you see

select what ?
this part i dont get it very well :-[