I'm having a difficult time figuring out what I'm doing wrong here. The window repaints fine until I add the tab control. When I add that, the richedit sitting on top of it refuses to repaint after another window covers/uncovers it. everything else seems to repaint fine. What am I doing wrong here?
$main
CONST EM_SETBKGNDCOLOR = (0x400 + 67)
CONST WS_VISIBLE = 0x10000000
'assume we want a 450x350 window
int width,height:width=450:height=350
int wl,wt,ww,wh
int cl,ct,cw,ch
WINDOW winMain
'
OPENWINDOW winMain,0,0,450,320,0x80CB0080|@MINBOX|@MAXBOX|@SIZE|@AUTOSCALE,NULL,"Control_ReSize_and_RePaint",&winMain_handler
'*************************************
CONST EM_SETBKGNDCOLOR = (0x400 + 67)
int i = 1
int adjustingWindow = 0
word tc = i: i++ ' tab control
word tb4[11]
tb4[0] = i: i++
word tb1 = i: i++
word tb2 = i: i++
word tb3 = i: i++
word btn1 = i: i++
word btn2 = i: i++
word btn3 = i: i++
adjustingWindow = 1
TabControl(winMain,5,5,280,80,@TCS_FOCUSNEVER|@TCS_TOOLTIPS|@TCS_SCROLLOPPOSITE|@TCS_BOTTOM,0,tc)
tcInsertTab(winMain,tc,0,"conn1")
CONTROL winMain,@RICHEDIT,"",10, 10,270,70,0x50B008C4 |@CTEDITMULTI|@CTEDITAUTOH|@CTEDITAUTOV,tb4[0] ' RCV Text Box
SETCONTROLCOLOR winMain, tb4, 0, 0
CONTROL winMain,@RICHEDIT,"",10,100,270,20,0x50810080 |@CTEDITAUTOH ,tb1 ' SND Text Box
CONTROL winMain,@RICHEDIT,"",10,100,270,20,0x50B008C4 |@CTEDITAUTOH ,tb2 ' AMX
CONTROL winMain,@RICHEDIT,"",10,100,270,20,0x50B008C4 |@CTEDITAUTOH ,tb3 ' Crestron
SETCONTROLNOTIFY(winMain,tb1,0,1)
CONTROL winMain,@BUTTON,"button &1" ,10,10,10,10,@TABSTOP|@CTLBTNDEFAULT, btn1 ' Send Button
CONTROL winMain,@BUTTON,"button &2" ,10,10,10,10,@TABSTOP , btn2 ' Copy AMX to Clipboard
CONTROL winMain,@BUTTON,"button &3" ,10,10,10,10,@TABSTOP , btn3 ' Copy Crestron to Clipboard
SendMessage winMain, EM_SETBKGNDCOLOR, false, RGB(0,0,0), tb4[0]
SendMessage winMain, EM_SETBKGNDCOLOR, false, RGB(0,0,0), tb1
ControlCmd (winMain,tb4[0],@RTSetDefaultFont,"Courier New",10,1,0)
'adjustingWindow = 0
resizeControls()
'resize the window
GETSIZE winMain,wl,wt,ww,wh
GETCLIENTSIZE winMain,cl,ct,cw,ch
SETSIZE winMain, wl,wt,ww-cw+width,wh-ch+height
'Show the window
SHOWWINDOW winMain,@SWRESTORE
'draw to show we are at desired size
'RECT winMain,0,0,width,height,RGB(255,0,0)
WAITUNTIL winMain = 0
tcDeleteAllTabs(winMain,tc)
CLOSEWINDOW winMain
END
SUB winMain_handler
SELECT @MESSAGE
CASE @IDCREATE
'hide the window
ModifyStyle #<WINDOW>@HITWINDOW,0,WS_VISIBLE
CASE @IDINITDIALOG
CENTERWINDOW winMain
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
gosub closeAndExit
case @IDSIZECHANGED
if adjustingWindow = 0
resizeControls()
endif
CASE @IDCONTROL
SELECT @CONTROLID
CASE btn1
IF @NOTIFYCODE = 0
/*button clicked*/
'resizeControls()
ENDIF
CASE btn2
IF @NOTIFYCODE = 0
/*button clicked*/
ENDIF
CASE btn3
IF @NOTIFYCODE = 0
/*button clicked*/
ENDIF
CASE tb4
/* respond to edit notifications here */
CASE tb1
/* respond to edit notifications here */
CASE tb2
/* respond to edit notifications here */
CASE tb3
/* respond to edit notifications here */
ENDSELECT
ENDSELECT
RETURN
ENDSUB
sub resizeControls
int left,top,width,height
'point p
adjustingWindow = 1
GetClientSize winMain, left, top, width, height ' always returns actual size of client area. left/top always return 0
print ""
print ""
print ""
print "GetClientSize"
print "left=" + str$(left) + " top=" + str$(top) + " width=" + str$(width) + " height=" + str$(height)
'if height < 100
' SETSIZE winMain, 0, 0, width, 100
'elseif width < 150
' SETSIZE winMain, 0, 0, width, 100
'else
SETSIZE winMain, 5, 5, width - 10, height - 100, tc
for i = 0 to 10
SETSIZE winMain, 10, 10, width - 20, height - 140, tb4[0]
next i
SETSIZE winMain, 10, height - 90, width - 100, 25, tb1
SETSIZE winMain, 10, height - 60, width - 100, 25, tb2
SETSIZE winMain, 10, height - 30, width - 100, 25, tb3
SETSIZE winMain, 10 + width - 100 + 10, height - 90, width - (width - 80) - 10, 25, btn1
SETSIZE winMain, 10 + width - 100 + 10, height - 60, width - (width - 80) - 10, 25, btn2
SETSIZE winMain, 10 + width - 100 + 10, height - 30, width - (width - 80) - 10, 25, btn3
'ENDIF
adjustingWindow = 0
ENDSUB
sub closeAndExit
' closes the window and sets winMain = 0
CLOSEWINDOW winMain
ENDSUB
Seems like I ran into problems before trying to put controls on an area that is inside the area allotted to a tabcontrol.
I know that when I use TC now I always have it 24 pixels high (to display just the tabs)
Observation: your code is kinda cryptic (to me).
Using word instead of int or const for ids
using the i++ thing to inc the numbers when you could define ids using ENUM
Using sendmessage to change control/window colors instead SETCONTROLCOLOR or SETWINDOWCOLOR.
Using MODIFYSTYLE to make a window visible instead of SHOWWINDOW
Not saying you're wrong or criticising. Just not use to seeing that.
To me it makes it look like a C programmer trying to program/learn EB.
Larry
The richedit isn't a child of the tab control in this case. It is a sibling, so you could try WS_CLIPSIBLINGS style on the tab control.
The ideal situation is to just use the tab control as a tab strip, and don't try to use it as a display surface, since Microsoft really didn't give it a lot of capabilities.
Another method is to use a temporary WINDOW variable and do this:
WINDOW tabctl
tabctl.hwnd = GetControlHandle(winMain,tc)
CONTROL tabctl,@RICHEDIT,"",10,100,270,20,0x50810080 |@CTEDITAUTOH ,tb1 ' SND Text Box
Of course you'll need to subclass the tab control if you want to get the notification messages from the richedit controls.
Paul.
This is the thread where I first ran into the problem and Paul told me to use the strip version of the tab.
http://www.ionicwind.com/forums/index.php/topic,2665.msg22497.html#msg22497
Larry
I tried using WS_CLIPSIBLINGS on the Tab control but it didn't help. Actually, the 'strip' version of the tab cntrl makes perfect sense and, come to think of it, I saw your earlier post. A no-brainer. I'll definitely go that way.
My code might appear a bit different. I have to write in three languages at work, mostly proprietary c-ish types. EB for fun at home. I tend to stick with things that work everywhere. Hence the i++. Trying to learn all of the keywords in all of the languages I use would simply overwhelm my little brain.
Thanks for the help, guys!
Paul, Your new network library is AWESOME! I am porting an old po**r bas*ic program and the speed difference is insane!
Quote from: rickmcneely on January 27, 2009, 08:37:45 PM
Paul, Your new network library is AWESOME! I am porting an old po**r bas*ic program and the speed difference is insane!
Thanks, if only more people knew that ;) And the network library is written in Emergence so thats a testament to the language as well.
Paul.