Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel 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:
'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:
'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
-
May be a problem elsewhere:
Test code:
%abc -2
sys a=-2
select a
case abc
print -2
end select
-
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?
-
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 ?
.
-
so far I suppose it's a simple programming mistake you've made, aurel.
this example works for me (first charles, second frank)
%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
-
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 ... ;)
-
Frank...
do you test this inside callback function?
Not work ...and why not ...looks like mistery ::)
-
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...
.
-
Oxygen Cases expect simple numbers
So expressions like 0-551 will not work
% 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.
-
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...
-
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.. ::)
-
Negative number equates: no problem, we use many of them.
The problem is that Cases do not understand expressions, only numbers or ascii characters.
-
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 ..
#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?
-
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.
-
hi kent..
rhis one :
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code)
{
case TCN_SELCHANGE:
as you see
select what ?
this part i dont get it very well :-[
-
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..
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
-
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 ???
-
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
-
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
-
Seems a little bit ignorance here.
TCN_SELCHANGING What ?
TCN_SELCHANGE = -551 This is the correct value.
-
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.
-
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.
-
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.
-
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.
-
Well, this works using the -2 notification:
It is based on the C example with all the nonsense taken out.
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
-
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
.
-
Here is the pointered instance:
case WM_NOTIFY :
NMHDR hdr at lparam
select hdr.code
case TCN_SELCHANGING
'leaving tab
case -2
'selected tab
...
-
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 ?
-
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.
-
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... ;)
-
Aaahh..after all this tricks
i have first version of ASciEdit with tabs
and you can try how work tab selecting .
so just open 2 or 3 files and try change tabs...
.
-
You earned that one. ;)
-
Aurel, you need to attach the latest awinh.inc, there are things missing in the version I have. Better to zip all dependencies, it is getting crazy keeping track of which is the latest version of stuff any of us have.
-
Sorry Kent
Look into attachment...
.
-
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.
Some of us need to understand why the wall is there in the first place.
-
Hmm...
It looks that NM_CLICK = -2
is not good solution because is triggered every time when leftMause button is clicked
on current tab.
I still search for right option and get something
( i still cannot found example (C) with tabbed editor)
but found one example in VB :
CASE WM_NOTIFY
NMHDR notify at lparam
Select notify.code
case -552 'TCN_SELCHANGING
'leaving tab
int p = GetSelectedTab(tc)
print "LEAVING->TAB:" + str(p)
autosave()':'FindTab()
case -551 'TCN_SELCHANGE
'selected tab
'autoSave()
'int i = GetSelectedTab(tc)
'print "SELECTED->TAB:" + str(i)
FindTab()
End Select
/* VB code
Select Case tNM.code
Case TCN_SELCHANGING
lTab = SelectedTab
RaiseEvent BeforeClick(lTab, bCancel)
If (bCancel) Then
ISubclass_WindowProc = 1
End If
Case TCN_SELCHANGE
lTab = SelectedTab
RaiseEvent TabClick(lTab)
Case NM_RCLICK
RaiseEvent TabRightClick
End Select
*/
I hope that i will fix this soon... ::)