How to change a button's visibility in VB6? - vb6

THE SITUATION
I am developing a VB6 application where all i need to do is to sync some files from a server location to the local workstation on a command click. There are two types of operations i am performing, in one m doing a complete sync, in the other i am doing a partial sync. Now when the sync is in progress i am displaying a screen which has a stop button on it. This stop is meant to stop the copying of media if the user wants to do so.
Now, this stop button is only visible when i am performing full sync. There is no option to stop the sync when partial sync is being performed.
The functions performing full sync and partial sync are written in a different class.
THE PROBLEM :
I have implemented all other functions but i having a problem in making this stop button dynamic..i.e. it is visible when full sync is bein called and invisible when partial sync is called.
Hope somebody helps
Thanks in advance

Set the Visible property to False to hide the button.

If I am understanding correctly, since the stop button is on a separate form it is not the case that there are other buttons on top of it- I had similar case myself.
What I can suggest is to check is whether both of the sync buttons are enabling the stop's button visibility when pressed.

I'd do it something like this:
Private sub cmdFullSync_Click()
'run existing code for a full sync
cmdStop.visible = true
end Sub
Private sub cmdPartialSync_Click()
'run existing partial sync code
cmdstop.visible = false
end Sub

Related

How to disable all user interaction for NSApplication/NSWindow without blocking the main thread?

I have a Cocoa app that presents a folder structure to the user and allows basic file system operations such as move/copy/rename.
I perform all file system access on a background queue and use file coordination via NSFileCoordinator.
Let's imagine the user drags the file "Notes.txt" into the folder "Project B". Here is what I do:
I schedule the file operation of moving the file on the background queue.
Once that's done, it calls a block on the main queue where I update the outline view
Let's assume the background operation moving the file takes some time. I need to prevent that the user continues to move files around or performs other actions until the first operation completes.
Hence I would like to:
Disable all user interaction with the window
Disable most menu items and keyboard shortcuts
Keep certain menus such as [Quit Cmd-Q] working
Don't block the main thread
One solution that comes to mind: use a modal sheet?.
I don't want to do this, because most of the time, the operation will finish quickly and the sheet would only be shown for a fraction of a second, which is distracting.
I keep track of how long the operation takes would switch from "interaction blocked mode" to "modal sheet" if it takes more than 500 ms.
The question is: how can I implement such a "user interaction blocked mode" without actually presenting a modal sheet?
Alternative idea: disabling all controls
I considered setting isEnabled = false for all controls, but that's not an option, because the UI can be arbitrarily complex and it won't prevent actions via the menu or keyboard shortcuts.
You may find helpful The Responder Chain article in Apple's Documentation. Proper solution depends on what you exactly need. Overriding NSMenu's - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; let you control over enable menu items and its shortcuts. You may also put transparent NSView over the area you want to prevent from user's interactions.

Not able to unload child(external) swfs that is loading from main(Navigation) movie as3

I have a Navigation.swf where i am loading multiple swfs using switch case statement based on the user choice (like a website navigation) aboutus.swf and contactus.swf etc, its loading perfectly.
Now in the child SWF's i have close_btn to unload the loaded SWF itself when user clicks on it. but i am not able to make it working. i have been reading help/articles form 2-3 months and found that it can be done using Event Dispatcher but somehow the codes i tried did not works for the close_btn. or it could not communicate to my main movie.
or do i need to load child swfs as movieclip ? to make the event dispatcher work from child swf so it can trigger the unloader function in main SWF and unload the loaded swf ?
please can u show me a code that can work
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i have found a temporary solution to this
but its worthless when my content position differ.
i have made a close button and hidden it on main( navigation movie) and when child swf is loaded i have made the close button visible, it works fine but button comes at a FIXED location on stage so the problem is if my content's postion is not near the close button then close button looks ODD on stage...so i have to have the close button inside the child SWF and not on the Main movie...
please see http://www.indianstitchers.com/ and click on facility to see how ODD the close button looks.
It's hard to help you without code samples. However I would recommend you to use LoaderMax which will make loading and unloading external media a piece of cake:
http://www.greensock.com/loadermax/
Hope that helps!
In the mean time you may try that:
in your main swif:
childSwif.addEventListener("closeChild", onChildClose);
function onChildClose(event:Event):void
{
removeChild(childSwif);
childSwif.unloadAndStop();
// or watever you need to do to close it
}
in your child swif:
dispatchEvent("closeChild");

Checking a Win32 Tree View Item Automatically Checks all Child Items

I am using the Win32 API and MS Visual C++ 6 to build a tree view of a directory structure, with check boxes associated with each tree view item. My goal is to be able to check a parent folder, and have that automatically check all of its associated children.
However, after digging through MSDN, I have not been able to find a control notification message for an item being checked, only when an item is selected. I have considered using a selection notification message to prompt the program to poll the item and see if its current 'check state' is true, but I am not sure that checked and selected can be tied together in such a way, and am also concerned about the overhead associated with constantly polling items as a user moves through a very large directory.
Has anyone had experience setting up this scenario? Are my concerns about the overhead of polling a GUI element justified?
There isn't any notification. You can write your own, though. Just handle mouse click and use hittest to see if the mouse cursor is on the state image. For completeness handle the space key and send the same notification for the selected item too.
As of Windows Vista, Microsoft has introduced NM_TVSTATEIMAGECHANGING and a corresponding NMTVSTATEIMAGECHANGING structure. I'm not sure why this is not documented with the Tree View notifications but instead in the General Control Reference section.
This notification code is sent by the tree control when the state image is changing (i.e. when the check box is clicked).
The NMTVSTATEIMAGECHANGING struct has a iOldStateImageIndex and iNewStateImageIndex field that specifies the corresponding change. This information can be used to determine the new state image that will be displayed (1 is the unchecked box and 2 is the checked box)
Vista also introduces dimmed, partial and excluded checks though at the moment I'm not sure how those are represented by the state image index as the two base cases above.
Here is the best way by MSDN (TreeView::AfterCheck Event):
http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.aftercheck(v=vs.110).aspx

Hidden Window Display on Users Desktop

We have a VB6 application that uses a non-visible window (form) for DDE communication.
We have some clients reporting that occasionally they can see this window on their desktop.
I did a scan through the code for any visible = true or show's on the form in question, but nothing.
This about all we do with it:
Load frmDDELink
frmDDELink.stuff = stuff
We don't actually explicitly display (or explicitly not display it either).
What could cause a hidden window to be displayed on a user's desktop such that it is visible?
Try and set the location of the form to off-screen.
frmDDELink.ClientLeft = -100
frmDDELink.ClientTop = -100
A misbehaving app on the client's machine could do that. FindWindow() is a notoriously inaccurate API function. On top of that, all VB6 windows have the same class name. Thunder something, iirc. It might be finding your window instead of the one intended, making the wrong window visible.
I like Black Frog's simple hint to set the location off-screen, and nobugz's possible explanation. I would also suggest handling the Form_Activate event and setting the form invisible again.
Private Sub Form_Activate()
'Log something for debugging purposes?'
Me.Visible = False
End Sub
try to set the border into none, or me.visible = false, and set the property not to display in the task bar.

Janus GridEX Problem

It's a longshot that anyone can help with this, but here goes. I inherited a VB6 app with a Janus GridEX control. It iterates through records, and is editable. Problem is, if I edit a cell and hit the button to go to the next record, the change is applied to the next record, not the one I was editing. It's like, I need it to finish up the edit before going to the next record. I've had this sort of problem before in VC++, and sometimes you have to "KillFocus" on the control you're on or something. I just don't know what to do here. I tried sending a carriage return, since if you return out of the edit cell, it works, but sending a carriage return manually doesn't work. What's the secret?
Is your grid bound or unbound?
It's hard to tell from your description, but I imagine that if your are having this problem then it's probably bound.
As the other answer asked, is the button the RecordNavigator that is built into the control or is it a separate button? The reason I bring this up again, is that I have seen issues in the VB6 applications I support where a toolbar will often intercept and interfere with how the JanusGrid should work.
To get around this limitation, I have added the following code in the click handler of any toolbars where there is also a JanusGrid control on the form.
If jsgxYourGridName.EditMode = jgexEditModeOn Then jsgxYourGridName.Update
This way any changes are immediately applied to the current row.
If this does not help, then I have also seen problems where the recordset that is bound to the grid gets out of sync with the internal recordset in the grid. You can check this by comparing the bookmark of the grid to the bookmark of the recordset.
Ie. mrsYourRecordset.Bookmark = jsgxYourGrid.ADORecordset.Bookmark
At one point I may have also used something like this.
jsgxYourGrid.ADORecordset.Bookmark = jsgxYourGrid.RowBookmark(jsgxYourGrid.RowIndex(jsgxYourGrid.Row))
Finally you can try setting a breakpoint in the BeforeUpdate, RowColChange and/or AfterColUpdate events of the grid, to see what record the grid is really on when clicking on the button.
It depends whether the button is internal to Janus GridEX or not. If it internal then just about the only thing you can do is look at the events the control exposes to see if there a sequence that can let you know that this problem occurs. Then you can try to take corrective action by restoring the row you moved to and put the edit in the row you left.
If the button is external to Janus then you can use the debug mode to trace sequence of statement that control the transfer of focus to the next row. It could be something out of order or a side effect of the particular sequence of commands. I have run into both with different controls.
Remember that you can edit while in debug mode so you can try different approaches and test until you find one that works.

Resources