I'm working with VB6.
I have several forms and i need open a form. This form have a UserControl.
My problem is setfocus in a element of UserControl inside this form.
Sub Form_Activate()
Ctrl_User.MyTextbox.SetFocus
End Sub
but don't run
How i can do it??
Thanks
Have you tried this:
Sub Form_Activate()
Ctrl_User.Enabled = True
Ctrl_User.MyTextbox.SetFocus
End Sub
Also maybe you may need to review this here as well it may help you more:
If you're authoring a user-drawn control, there won't be any
constituent controls on your UserControl. If you don't want your
control to be able to receive the focus, set the CanGetFocus property
of the UserControl object to False. CanGetFocus is True by default.
If your user-drawn control can receive the focus, the UserControl
object will receive GotFocus and LostFocus events when your control
receives and loses the focus. A user-drawn control is responsible for
drawing its own focus rectangle when it has the focus, as described in
"User-Drawn Controls," in this chapter.
This is the only function your UserControl's GotFocus and LostFocus
events need to fulfill for a user-drawn control. You don't need to
raise GotFocus or LostFocus events for the user of your control,
because the container's extender provides these events if the
CanGetFocus property is True.
https://msdn.microsoft.com/en-us/library/aa241743(v=vs.60).aspx
Related
I need to make a Timage item hide or disappear after a certain key is being pressed, while the program is still running.
I know that onKeyPress method can't really make changes to the Graphic items such like Timage, so is there any other alternative ways which I could use for my situation?
Set KeyPreview of the form to true and write an OnKeyPress|Down|Up event for the form, where you hide that TImage.
How to "notify" the parent window about the "scroll event" of its child window, a "list box" control, each time it is scrolled up or down in WIN32 API?
I am trying to make a dictionary using the WIN32 API. I created a parent window, and then created a child window list box control in it.
I want to add "50 word lists" at a time to the list box control from the database, so that the application does not take time at all during the start up.
And then, I want to keep a track of the "scroll bar position" (the "SCROLLINFO" structure's "nPos" value) of the list box control as the user scrolls up or down the word lists, so that I can call a function that adds 50 more words at the end of the list box when it has been almost scrolled up to the bottom.
In the main window procedure function, inside the "switch" statement I used the "WM_VSCROLL" window message hoping to catch the child window list box control’s scroll event. The child window list box control has "LBS_NOTIFY" style. But all in vain! The list box control’s scroll event is not being notified to its parent window. The parent window also is not doing anything in the "WM_VSCROLL" message for its child window list box control’s scroll event.
Please kindly help me, guide me, show me with code examples how to "notify" the parent window about the "scroll event" of its child window, a "list box" control, each time it is scrolled up or down in WIN32 API.
Scrolling messages are only sent to the window that is actually being scrolled, in this case the ListBox. LBS_NOTIFY only applies to a few select messages, which do not include scrolling messages. You would have to subclass the ListBox via either SetWindowLongPtr(GWL_WNDPROC) or SetWindowSubclass() and have your subclass procedure catch the scrolling messages and forward the info to the parent window as needed.
I am new to interface design and I would like to have my own custom software interface. I using C#.net either windows form or wpf.
Let's say I have a background image (the whole interface design), can I detect a certain mouse click event on only a certain area of the background? Like say the "login" button which I drew on background (Not a button control from the framework) so that I make it function like a button.
Or I have to do the background design separately and make the "login" button drawing a picture box control and creating events from there?
Like this ..
There's form with background image + button image in picturebox (transparent backcolor)
Test with mousehover on the button image
Private Sub PictureBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
MsgBox("hi")
End Sub
I have a wxPython grid (wx.grid) class with rows/columns and such. I'm trying to detect when the user performs a "Control + Click" on a particular cell. Right now I have:
def __init__(self, parent, size):
grd.Grid.__init__(self, parent, -1, size=size)
self.control_button_pressed = False
self.Bind(grd.EVT_GRID_CELL_LEFT_CLICK, self._OnSelectedCell)
self.Bind(wx.EVT_KEY_DOWN, self._OnKeyPress)
self.Bind(wx.EVT_KEY_UP, self._OnKeyUp)
def _OnKeyPress(self, event):
self.control_button_pressed = True
event.Skip()
def _OnKeyLift(self, event):
self.control_button_pressed = False
def _OnSelectedCell(self, event):
print "Cell Selected"
This works fine when just clicking on the cell, but when I perform a Control + Click, this event doesn't even fire.
How can I bind this event?
The Grid class is already handling Ctrl-Click events to implement adding cells to the collection of selected cells. Since the grid is already consuming that event for that purpose then the event is not propagated or converted into grid events (other than selection events.) However you can intercept the lower level mouse events before the grid gets them, and do your checks there. Try binding handlers directly to the grid window component of the Grid, like this:
self.GetGridWindow().Bind(wx.EVT_LEFT_UP, self.onLeftUp)
Be sure to call event.Skip() in your mouse event handler so the Grid can still get and process the event.
You do not have to worry about catching the key events for this because the event object passed to the mouse event handlers includes methods for getting the state of the modifier keys at the time that the mouse event happened.
I think you'll need to bind to EVT_KEY_DOWN and EVT_KEY_UP. In the key down event, set some variable like "self.ctrl" to True. In the up event, set it to False. You should probably initially set it to False as well. Then when it's held down, it becomes True and as long as you call event.Skip(), your grid event should fire when you click. Something along those lines should work anyway.
This might help you understand key events better: http://www.blog.pythonlibrary.org/2009/08/29/wxpython-catching-key-and-char-events/
Never mind this answer --> see Robin Dunn's
How to detect a mouse click (or mousedown) event on a simple dropdown combo (combobox with style=1)?
I am unable to see mouseclick or mousedown event handlers for combobox in my vb6 IDE.
My aim is to detect right click.
Thanks in advance.
If the events aren't exposed, you may need to subclass the control and handle the WM_RBUTTONDOWN message.