Author Topic: tabControl & TCN_SELCHANGE  (Read 12327 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #15 on: October 19, 2013, 01:24:05 AM »
aurel, I don't know what's your aim for tab control and try to specify your intention. it's irrelevant, if the equate is negative or positive number, it's a programming structure you have to solve as I did say before.. in your sci editor example there a lot of "controlID"'s and you used "tcID" three or four times what's no need for it...

...%TCN_SELCHANGING ...

powerbasic code part only as idea for going on there with your task..


Code: [Select]
   CASE %WM_NOTIFY
        SELECT CASE CBWPARAM                      '<- trap tab page selection
           CASE %ID_TAB
              LOCAL lpNmh AS NMHDR PTR, lPage AS LONG
              lpNmh = CBLPARAM
              lPage = TabCtrl_GetCurSel(GetDlgItem(CBHNDL, %ID_TAB))

              SELECT CASE @lpNmh.Code
                 CASE %TCN_SELCHANGING ' The page is about to change
                       DIALOG SHOW STATE hTab(lPage), %SW_HIDE

                 CASE %TCN_SELCHANGE
                       DIALOG SHOW STATE hTab(lPage), %SW_SHOW
               END SELECT
        END SELECT



regards, frank

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #16 on: October 19, 2013, 02:27:25 AM »
frank
of course that there are a lot of controlID-s because as you may see
each controlID is ID of each toolbar button or specific control..right?
In this case tcID is ID of tab control and this is standard ID creted with CreateWindowEx()...
and there is nothing ultra-special about that .
problem is how properly intercept TCN_SELCHANGE which is -551 and it looks to me that oxygen
think that this number is not valid...somehow.
Also as you can see if you look into listbox notification message
'doubleClick listbox item -> jump to line
  IF notifycode = LBN_DBLCLICK

this message is processed properly without problem.
I undestand that tab control need NMHDR structure
and that must be triggered under WM_NOTIFY message
and when i add this structure still
TCN_SELCHANGE is not intercepted...why ?
maybe i don't know which way i must use ....of course i try Eros example from thinbasic
but it looks that oxygen don't respond on that way...

As i say i cannot found Free basic example..maybe is there something different ???

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #17 on: October 19, 2013, 03:22:03 AM »
Hi Aurel,

I have your C example working partially. I think the C code was buggy, but I will try to get it to do something useful. The tabs are responding on code -552: TCN_SELCHANGING, not -551

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #18 on: October 19, 2013, 03:54:04 AM »
Charles
Do you can post here this C translated code ?
or you try wirh C compiler?
i really dont understand why for example almost same code work without problem in
EBasic for example?
And Charles
please don't get me wrong but i think that something is wrong with
CASE or END IF and with combination with THEN...
as i say many times i like option without THEN and make much more sense
to use THEN in line...ok...
thanks

Peter

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #19 on: October 19, 2013, 04:31:46 AM »
Seems a little bit ignorance here.

TCN_SELCHANGING  What ?

TCN_SELCHANGE = -551  This is the correct value.
 

JRS

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #20 on: October 19, 2013, 08:18:38 AM »
Quote
Seems a little bit ignorance here.

Don't be hard on Aurel. After you run into the wall enough times, words start looking the same and assumptions become reality.

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #21 on: October 19, 2013, 09:00:40 AM »
Quote
Seems a little bit ignorance here.

TCN_SELCHANGING  What ?

TCN_SELCHANGE = -551  This is the correct value.

What ...what?
TCN_SELCHANGING  = -552
TCN_SELCHANGE     = -551

and what?
what kind of ignorance ,there is no ignorance at all.



Peter

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #22 on: October 19, 2013, 09:17:37 AM »
Quote
After you run into the wall enough times,

When I stand in front of a wall, neither I run into the wall nor I run against the wall, rather I jump over the wall.

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #23 on: October 19, 2013, 09:22:06 AM »
The only notifications I get for the tab control are -552 and -2

Unfortunately with the -552 notification,  TCM_GETCURSEL only indexes the TAB you are leaving, not the tab you have selected.
« Last Edit: October 19, 2013, 10:01:25 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #24 on: October 19, 2013, 09:58:11 AM »
Well, this works using the -2 notification:

It is based on the C example with all the nonsense taken out.

Code: [Select]


includepath "$/inc/"
include "minwin.inc"

% TCIF_TEXT       1
% TCN_SELCHANGE   -551
% TCN_SELCHANGING -552
% TCM_INSERTITEM  0x1307
% TCM_GETCURSEL   0x130B
% TCM_SETCURSEL   0x130C

% COLOR_WINDOW    5

type NMHDR
  sys hwndFrom,idFrom,code
end type

type TCITEM
  int   mask,dwState,dwStateMask
  char* pszText
  int   cchTextMax,iImage
  sys   lParam
end type

sys hWndMain,hWndTab,hwnd0,hinst

Declare Sub InitCommonControls lib "comctl32.dll" ()

 
function MakeWindow(sys num)
============================
hwnd0=CreateWindowEx(0,"edit", "text "+num+1, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS,
                     0,28,300, 300,
                     hwndTab, NULL, hinst, NULL)
end function

 
function WndProc(HWND hwnd, UINT ms, wParam, lParam) as sys callback
====================================================================
static int iPage=-1
select ms
case WM_CLOSE   : DestroyWindow(hwnd)
case WM_DESTROY : PostQuitMessage(0)
case WM_NOTIFY  :
  NMHDR hdr at lparam
  select hdr.code
  case TCN_SELCHANGING
    'leaving tab
  case -2
    'selected tab
    int i = SendMessage(hwndtab,TCM_GETCURSEL,0,0)
    if i<>iPage
      iPage=i
      DestroyWindow hwnd0
      MakeWindow(iPage)
    end if
  end select
case else : return DefWindowProc(hwnd, ms, wParam, lParam)
end select
end function
 

function WinMain(sys hInstance, hPrevInstance, char*lpCmdLine, int nCmdShow) as sys
===================================================================================
WNDCLASSEX wc
sys        hwnd
MSG        ms

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 = COLOR_WINDOW+1
wc.lpszMenuName  = NULL
wc.lpszClassName = strptr "myWindowClass"
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION)
 
rg=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"
SendMessage hwndTab,TCM_INSERTITEM,0,@tie
tie.mask = TCIF_TEXT
tie.pszText = "Hi2"
SendMessage hwndTab,TCM_INSERTITEM,1,@tie
tie.mask = TCIF_TEXT
tie.pszText = "Hi3"
SendMessage hwndTab,TCM_INSERTITEM,2,@tie
tie.mask = TCIF_TEXT
tie.pszText = "Hi4"
SendMessage hwndTab,TCM_INSERTITEM,3,@tie
 
SendMessage hwndTab,TCM_SETCURSEL,3,0
'print SendMessage hwndTab,TCM_GETCURSEL,0,0

ShowWindow(hwndTab, SW_SHOW)
UpdateWindow(hwndTab)
 
while(GetMessage(&ms, NULL, 0, 0) > 0)
  TranslateMessage(&ms)
  DispatchMessage(&ms)
wend
return ms.wParam
end function


char*cmdline
sys inst
&cmdline=GetCommandLine
inst=GetModuleHandle 0
WinMain inst,0,cmdline,SW_NORMAL
end

« Last Edit: October 19, 2013, 10:13:56 AM by Charles Pegge »

kryton9

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #25 on: October 19, 2013, 11:41:44 AM »

Aurel's c code compiled and ran fine Charles. The compiled exe is in :Aurel.c\bin\Release


From MSND:
typedef struct tagNMHDR {
  HWND     hwndFrom;
  UINT_PTR idFrom;
  UINT     code;
} NMHDR;


How come this doesn't have pointer?
type NMHDR
  sys hwndFrom,idFrom,code
end type



.
« Last Edit: October 19, 2013, 11:56:07 AM by kryton9 »

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #26 on: October 19, 2013, 11:48:44 AM »
Here is the pointered instance:

case WM_NOTIFY  :
  NMHDR hdr at lparam
  select hdr.code
  case TCN_SELCHANGING
    'leaving tab
  case -2
    'selected tab
...


Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #27 on: October 19, 2013, 11:52:41 AM »
thanks Charles..
yeah...lot of nonsense i agree but that is the way how work...
i still don't get it why notifycode not work  ::)

just one small question...
what exectly mean :
NMHDR hdr at lparam

what is at?
Is this something like CAST ?

Charles Pegge

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #28 on: October 19, 2013, 12:13:04 PM »
Yes it is very similar to  casting, since hdr and lparam share the same memory slot.

It dims hdr as an NMHDR pointer and its address is the value of lparam.

Aurel

  • Guest
Re: tabControl & TCN_SELCHANGE
« Reply #29 on: October 19, 2013, 02:43:55 PM »
Thanks Charles...
It work and it looks that this is the only way for tab selection.
Now i must rearange all complex file-tab-name work to do
to set that everything work fine in ASciEdit... ;)