Below is a simple routine it am using reading the mouse coordinates. When I start the program and start reading mouse coordinates , I get an error message saying that the window or dialog is not open. I know the window is open . I am using multiple windows . I am reading coodinates off of one window and display those coodinates on the main window. Can anyone guess what I might be doing wrong??
SUB MOUSEMOVE
xx$=STR$(@mousex)
SETCONTROLTEXT wMain1,57,xx$
'--------------------------
yy$=STR$(@mousey)
SETCONTROLTEXT wMain1,58,yy$
return
Thanks Texas Pete
You're going to have to show more code than that.
QuoteI get an error message saying that the window or dialog is not open. I know the window is open .
Larry
Mouse message can not be read if window dont exist ???
TexasPete,
Without additional code to work with or knowing exactly what you are trying to accomplish...
...for testing purposes, try adding something like this to your main window handler:
case @IDMOUSEMOVE
setcontroltext wMain1,57, STR$(@mousex)
setcontroltext wMain1,58, STR$(@mousey)
If needed, I'm guessing that you could call your existing sub routine directly from the @IDMOUSEMOVE routine just as easily.
HTH,
-Doc-
Everybody I figured it out. Sometimes I just need a little point in the right direction. Thanks for those that replied. My solutions was !!!
I had the @IDCLOSEWINDOW in the wrong place. However, I don't understand why the window was still open and visible on the screen while
the main window had been accidently closed.
Texas Pete
you probably don't have the window declared properly.
But all of us can only guess when you don't provide the code to look at.
And it makes it even worse when you don't provide code and make absolute assertions ("I know the window is open") that we can't verify.
Eventually people will tire of having to "guess" in order to help you and I think you'll find that your help will drop off.
Larry
Thanks Everyone who tried to help.
Below is a simple example solution for reading mouse coordinates.
In Lb you did not have to do this. In CB doing it this way does gives the
programmer more control over what is going on in the program.
'-------------------- Simple Solution for Reading Mouse Coordinates
declare "user32",SetWindowPos(Hwnd:int,HwndAfter:int,x:int,y:int,cx:int,cy:int,flags:int)
setid "SWP_NOMOVE",2
setid "SWP_NOSIZE",1
setid "HWND_TOPMOST",-1
setid "HWND_NOTOPMOST",-2
'TexasPete Scroll---------------------
def win1:window
def win2:window
def wMain1:window
'def GraphicBox:window
def wstyle1:int
DEF wstyle2:int
def ScreenWidth:int
def ScreenHeight:int
def x,y,w,h:int
def x2,y2,w2,h2:int
def a$,newline,x$,y$:string
def handle:int
def CursorHandle:int
def MinScroll:int
Def MaxScroll:int
Def VertScroll:int
def HorzScroll:int
def PositionScroll:int
def Mainstyle:int
def MainWidth:int
def MainHeight:int
VertScrol=-2
HorzScrol=-1
'add to win2 + 600 pixels
h2=600
w2=600
wstyle1 = @VSCROLL|@HSCROLL|@NOCAPTION
wstyle2 = @NOCAPTION
Mainstyle=@MINBOX|@MAXBOX|@SIZE
'----Get the size of the screen---------------------
' i'm curently using 800x600
GETSCREENSIZE ScreenWidth,ScreenHeight
MainWidth=ScreenWidth
MainHeight=ScreenHeight
'-----------------------------------------------
Window wMain1,0,0,MainWidth,MainHeight,Mainstyle,0,"Main Window Basic",main1
'Set Window Height and Width in main window create
'Main Window - parent
ScreenWidth=ScreenWidth-200:ScreenHeight=ScreenHeight-200
'----------------------------------------------------------------------
Window win1,100,100,ScreenWidth,ScreenHeight,wstyle1,0,"Main Scrolling Window",main1
SETWINDOWCOLOR win1,rgb(0,0,40)
'----second window child -----------
Window win2,0,0,ScreenWidth,ScreenHeight,wstyle2,win1,"Child Window ",main2
SETWINDOWCOLOR win2,rgb(190,200,240)
CONTROL wMain1,"E,,16,1,50,18,0x50802800,1"
SetFont wMain1,"MS Sans Serif",8,400,0,1
CONTROL wMain1,"E,,80,1,50,18,0x50802800,2"
SetFont wMain1,"MS Sans Serif",8,400,0,2
CONTROL win1,"E,,16,1,50,18,0x50802800,17"
SetFont win1,"MS Sans Serif",8,400,0,17
CONTROL win1,"E,,80,1,50,18,0x50802800,18"
SetFont win1,"MS Sans Serif",8,400,0,18
'--------Set the scroll ranges---------------------
SETSCROLLRANGE win1,-2,1,600
SETSCROLLRANGE win1,-1,1,600
Rect win2,99,29,402,302,rgb(0,150,150)
Move win2,100,100:Print win2,"A Simple"
Move win2,100,130:Print win2,"Creative Window"
Move win2,10,550:Print win2,"This text is visible after you move Vscrollbar"
Circle win2,400,550,100
'------------------------
Waituntil win1 = 0
END
'--------------------
SUB main1
'----------------gosub mouse
SELECT @CLASS
CASE @IDVSCROLL : ' Vertical Scrollbar @message
SELECT @CODE
CASE @SBLINEUP
SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))-10
CASE @SBLINEDOWN
SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))+10
CASE @SBPAGEUP
SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))-50
CASE @SBPAGEDOWN
SETSCROLLPOS win1,-2, (GETSCROLLPOS(win1,-2))+50
CASE @SBTHUMBPOS
SETSCROLLPOS win1,-2, @QUAL
CASE @SBTHUMBTRACK
SETSCROLLPOS win1,-2, @QUAL
ENDSELECT
SetSize win2,0,-GETSCROLLPOS(win1,-2),ScreenWidth,ScreenHeight+h2
'*********PETE: I moved your mouse handler as shown below ******************************
CASE @IDMOUSEMOVE
'gosub mouse
'----------------------------------------------------------------
CASE @IDHSCROLL
SELECT @CODE
CASE @SBLINELEFT
SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))-10
CASE @SBLINERIGHT
SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))+10
CASE @SBPAGELEFT
SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))-50
CASE @SBPAGERIGHT
SETSCROLLPOS win1,-1, (GETSCROLLPOS(win1,-1))+50
CASE @SBTHUMBPOS
SETSCROLLPOS win1,-1, @QUAL
CASE @SBTHUMBTRACK
SETSCROLLPOS win1,-1, @QUAL
ENDSELECT
SetSize win2,-GETSCROLLPOS(win1,-1),0,ScreenWidth+w2,ScreenHeight
'----------------------------
Case @idclosewindow
'becose we have win2 as child win in main1 win2 is closed automaticly
Closewindow wMain1
'*********PETE: I uncommented this portion of your code ******************************
Closewindow win1
ENDSELECT
RETURN
SUB main2
SELECT @CLASS
CASE @IDMOUSEMOVE
gosub mouse
CASE @IDCLOSEWINDOW
run = 0
CLOSEWINDOW win2
CLOSEWINDOW win1
ENDIF
ENDSELECT
RETURN
IF @CLASS = @IDCLOSEWINDOW
REM closes the window and sets w1 = 0
'***************************************
CLOSEWINDOW win2
CLOSEWINDOW win1
ENDIF
RETURN
SUB mouse
'SETFOCUS mywin,17
x$=STR$(@mousex)
SETCONTROLTEXT win1,17,x$
SETCONTROLTEXT wMain1,1,x$
'--------------------------
'SETFOCUS mywin,18
y$=STR$(@mousey)
SETCONTROLTEXT win1,18,y$
SETCONTROLTEXT wMain1,2,y$
return
Thanks to Doc , Aurel, and Larry who offers good advice.
Texas Pete
P.S I finished translating My first page from LB to CB. I have about 8 or nine more to go! I think it will start to move a little faster now.
Not bad but i think that would be better place edit controls in main window not in scrolling.
And one thing,please use button # code for code in post.
all best
Aurel
Pete, what aurelCB is suggesting is that you paste your code in brackets like this to make it easier for folks to read and/or to offer help.
It really isn't a big deal for small snippets, but it's a good practice if you have quite a bit of code to share...
....and folks will appreciate it when you do.
Best regards,
-Doc-
Ok , Everybody I will use the brackets next time. I promise scouts honor!
Thanks
Texas Pete