Using the CONTROL statement, I created a button control.
During later processing, I would like the button to disappear as I don't need it anymore.
I don't see a command to do this.
Any ideas?
Thanks.
			
			
			
				This may not be 100% of what you are trying to do, but:
ENABLECONTROL window | dialog, ID, 0 | 1
The ENABLECONTROL function enables or disables a control in a window or dialog. Controls that are disables are grayed out and cannot be selected. Use 0 to disable the control or 1 to enable. Example: ENABLECONTROL mydialog, 2, 0
You can always disable the control.
Hope this helps,
Bill
			
			
			
				To actually hide the button you would use:
SHOWWINDOW  window | dialog, @SWHIDE, ID
To delete it (to never used again) use:
DECLARE IMPORT,DestroyWindow(hwnd as UINT),INT 
DestroyWindow(GetControlHandle(mywin, ID))  
LarryMc
			
			
			
				Larry,
I tried your method by coding this -->  SHOWWINDOW  mywindow, @SWHIDE, 1
			
			
			
				Larry,
I tried your method by coding this -->  SHOWWINDOW  mywindow, @SWHIDE, 1 
where 1 is the ID of my button control.  Instead of making the button disappear, the whole window disappears!
Am I not coding this correctly?
Thanks.
			
			
			
				SHOWWINDOW  mywindow, @SWHIDE, 1  is correct if the window is defined as mywindow and the button was created with a control id of 1.
If that's true then the only way I can help you is by you posting your source as I said earlier (or emailing it to me).
BTW, what version of IWB/EB are you using?
LarryMc
			
			
			
				Larry,
The EBasic version I have is 1.735
Would there be a good reason for me to upgrade to IWBasic?
			
			
			
				ver 1.735 is new enough that it isn't causing your problem.
so I would wait for 2.0 to be released before updating.
LarryMc
			
			
			
				Quick example:
Dim w As Window
OpenWindow w,0,0,380,340,@MinBox,null,"Hide/Show Controls",&wp
Control w,@Button,"Show",0,0,90,20,0,1
waituntil iswindowclosed w
end
sub wp
	select @message
		case @idclosewindow
			closewindow w
		case @idlbuttondn
			showwindow w,@swhide,1
	endselect
endsub
This works in EBasic v1.735
			
			
			
				@WayneA
Look in this thread to see why I asked to see his code for something that seems minor to us.
http://ebasic-aurora.com/forums/index.php?topic=4384.msg34033#msg34033
LarryMc
			
			
			
				I hope you didn't interpret my post as a suggestion that you couldn't or wouldn't provide an example Larry. I've been around long enough to know you'll go out of your way to help anyone.
Honestly, I just glanced at the thread and noticed there was no example, so I wrote a quick one to see if there was actually a bug. I hadn't even read the part where you asked to check out the source code. 
			
			
			
				Quote from: WayneA on January 13, 2011, 10:07:15 PM
I hope you didn't interpret my post as a suggestion that you couldn't or wouldn't provide an example Larry. 
No, I didn't take it that way.  I just posted in case you were curious as to why I didn't post a little similar example.
LarryMc
			
 
			
			
				Here are snipets of code that open a window, setup a button control in it, populate the button with a .BMP and then trying to hide the button:
OPENWINDOW part1MDI,0,0,1400,860,@USEDEFAULT|@SIZE,0,"MatchEm - Part 1",&mainpart1MDI
CONTROL part1MDI,@BUTTON,"",600,10,100,100, @CTLBTNBITMAP, 0
SETCONTROLTEXT part1MDI, 0, PicFilesDir + "TEST.BMP"
SHOWWINDOW  Part1MDI, @SWHIDE, 0
Result: the entire window becomes hidden.  In SHOWWINDOW, the ID seems to be ignored.
I also tried using a number > 0 for the ID but the same result.
Thanks.
			
			
			
				I've never tried it but I don't think you can have a control with an ID of 0
OPENWINDOW part1MDI,0,0,1400,860,@USEDEFAULT|@SIZE,0,"MatchEm - Part 1",&mainpart1MDI
1st off, since the above window (part1MDI) was created without the @MDIFRAME flag it is a child window.
But you have a parent of 0 which says it isn't a child window
(without the rest of your code as I have mentioned before I don't know which you intended this to be)
CONTROL part1MDI,@BUTTON,"",600,10,100,100, @CTLBTNBITMAP, 0SETCONTROLTEXT part1MDI, 0, PicFilesDir + "TEST.BMP"
This line is okay if and only if the parent window is created a child window when used in a MDI configuration.
SHOWWINDOW  Part1MDI, @SWHIDE, 0
Again, this line of code can only work when it's parent is set up properly.
There are people here who are more than willing to help you if you present the full picture.  Otherwise we all waste a lot of time trying to guess.
I also suggest, again, you read the MDI section in the help file AND make a copy of the mdidemo file to test on.
LarryMc
			
			
			
				modified demo program
'Compile as a WINDOWS target
DEF frame,neww[ 20 ]:WINDOW
DEF run,wndcnt,x:INT
DEF stattext:STRING
'open the frame
OPENWINDOW frame,0,0,640,480,@MDIFRAME|@MINBOX|@MAXBOX|@SIZE|@MAXIMIZED,0,"MDI Demo",&wndproc
'Use INSERTMENU with @MDIFRAME windows so we dont erase the standard menu
BEGININSERTMENU frame,0
	MENUTITLE "&File"
	MENUITEM "&New",0,1
	MENUITEM "&Quit",0,2
ENDMENU
DEF tbArray[10]:INT
tbArray = 2,3,4,0,5,6,7,0,8,9
IF LOADTOOLBAR(frame,0,98,tbArray,10,@TBTOP )
	CONTROLCMD frame,98,@TBSETLABELS,"New|Open|Save|Cut|Copy|Paste|Print|Help||"
	CONTROLCMD frame,98,@TBRESIZE
ENDIF
run = 1
wndcnt = 0
'process messages until someone closes us
WAITUNTIL run = 0
CLOSEWINDOW frame
END
'our window subroutine for the frame and child windows
SUB wndproc
SELECT @CLASS
	CASE @IDCLOSEWINDOW
			run = 0
	CASE @IDCONTROL
		SELECT @CONTROLID
			CASE 2
				OpenNewWindow()
		ENDSELECT
	CASE @IDMENUPICK
		SELECT @MENUNUM
			CASE 1
				OpenNewWindow()
			CASE 2
				run = 0
		ENDSELECT
ENDSELECT
RETURN
ENDSUB
SUB OpenNewWindow
	wndcnt = -1
	FOR x=0 TO 19
		IF neww[x] = 0
			wndcnt = x
			x=19
		ENDIF
	NEXT x	
	IF wndcnt > -1
		name$ = "Untitled"+LTRIM$(STR$(wndcnt+1))
		OPENWINDOW neww[wndcnt],@USEDEFAULT,0,0,0,@SIZE|@MINBOX|@MAXBOX,frame,name$,&childwndproc
		CONTROL neww[wndcnt],@button,"Hide",60,60,100,20,0,3
		CONTROL neww[wndcnt],@button,"Show",60,90,100,20,0,4
	ENDIF
RETURN
ENDSUB
SUB childwndproc
SELECT @CLASS
	case @idcreate
	CASE @IDCLOSEWINDOW
		CLOSEWINDOW #<WINDOW>@HITWINDOW
	CASE @IDCONTROL
		SELECT @CONTROLID
			CASE 3
				showwindow #<WINDOW>@HITWINDOW,@swhide,3
			case 4
				showwindow #<WINDOW>@HITWINDOW,@swshow,3
		ENDSELECT
ENDSELECT
ENDSUB
LarryMc
			
			
			
				Aye, don't use 0. Functions that accept optional controlid parameters use 0 as the default "no control id is provided" value. So when you tried to hide the control you were actually telling windows to hide the parent.
			
			
			
				Thanks Larry,
I can see that the structure of my program is far from standard due to lack of understanding and experience with Windows programming.  I don't want to take the time to restructure it since it is working well now with the structure it has (though there are some nice-to-have's like removal of a control, exiting the listbox correctly), I don't want to spend any more time on this.  My next project will be better thanks to all of your help.
I have one more question: this program display's nicely on my Windows Vista development PC but yesterday I ported it to my older Windows XP  laptop.  The window sizes in the program are 1400 by 840 and when they display on my laptop, they go off the screen to the right and bottom.  I would have thought that Windows would have automatically resized/scaled it to fit the screen.  Is there something my program lacks which causes this?
Thanks.
			
			
			
				Quote from: plurald on January 14, 2011, 03:07:54 PM
I have one more question: this program display's nicely on my Windows Vista development PC but yesterday I ported it to my older Windows XP  laptop.  The window sizes in the program are 1400 by 840 and when they display on my laptop, they go off the screen to the right and bottom.  I would have thought that Windows would have automatically resized/scaled it to fit the screen.  Is there something my program lacks which causes this?
What you have run into is what everyone that writes programs for other users has to account for.
You have to incorporate into your program the screensize of the user and make the necessary adjutments.  Also, unless the application is a graphics type program you need to allow and account for a user resizing your window to suit their taste (but not in all cases)
I write my apps for a 1024x768 which almost all users have nowadays.  But I still allow resizing where at all possible.
There are commands for getting the user's screen size and for the program to resize and or move things around and also to add scrollbars if necessary.  There are messages that the OS sends to your windows that says they are being resized where you can check to see what the new size is and make adjustments.  Sometimes it can be a lot of work.
So, to answer your question
QuoteIs there something my program lacks which causes this?
The answer is absolutely yes.
LarryMc