473,856 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send Key Commands to modeless dialog box

1 New Member
Hi

I am programing in Autocad with VB

Autodesk have not given users access to new note function in Autocad CIVIL3d API. I am trying to work round this by creating notes using the sendkey command in Vb. I can get the add note dialog box to come up ok but it does not have focus as I believe it is a modeless dialog box as it gets focus when you move the mouse cursor over it.

What I am after is a VB eample on how to send key strokes to the modeless dialog. Looking on the web a I think I have to use the
IsDialogMessage () in combination with others.

Any help on getting this rountine to work would be great here is the code I sourced from others and written so far.

I seem to be able to get the window handle and send commands but still nothing happens. All it needs to do in press the tab key 3 times to got tru controls on the form and get to a buttton and press.



'Type to hold the coordinates of the mouse pointer
Private Type POINTAPI
x As Long
y As Long
End Type

'Type to hold the Windows message information
Private Type MSG
hWnd As Long 'the window handle of the app
message As Long 'the type of message (e.g. keydown)
wParam As Long 'the key code
lParam As Long 'not used
time As Long 'time when message posted
pt As POINTAPI 'coordinate of mouse pointer
End Type


Public Declare Function EnableWindow Lib "user32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindow A" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindow ExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageLong & Lib "user32" Alias "SendMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Public Declare Function SendMessageBySt ring Lib "user32" Alias "SendMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Declare Function showwindow Lib "user32" Alias "ShowWindow " (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function IsDialogMessage Lib "user32" (ByVal hWnd As Long, ByRef lpMsg As MSG) As Long


Public Const BM_SETCHECK = &HF1
Public Const BM_GETCHECK = &HF0

Public Const CB_GETCOUNT = &H146
Public Const CB_GETLBTEXT = &H148
Public Const CB_SETCURSEL = &H14E

Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5

Public Const LB_GETCOUNT = &H18B
Public Const LB_GETTEXT = &H189
Public Const LB_SETCURSEL = &H186

Public Const SW_HIDE = 0
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_NORMAL = 1
Public Const SW_SHOW = 5

Public Const VK_SPACE = &H20

Public Const WM_CHAR = &H102
Public Const WM_CLOSE = &H10
Public Const WM_COMMAND = &H111
Public Const WM_GETTEXT = &HD
Public Const WM_GETTEXTLENGT H = &HE
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_LBUTTONDBLCL K = &H203
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_MOVE = &HF012
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_SETTEXT = &HC
Public Const WM_SYSCOMMAND = &H112

Sub GetWindowhandle ()

Dim hWnd As Long
Dim Messageprocesse d As Variant

hWnd = FnFindWindowLik e("Add Labels")
MsgBox hWnd

Tabthrucontrols ondialog hWnd


End Sub


Sub Tabthrucontrols ondialog(hWnd As Long)

'Dim x As Long

'x = FindWindow("#32 770", vbNullString)
'Call showwindow(x, SW_SHOW)
Call EnableWindow(hW nd, 1)

'check modeless child window enabled and visible
MsgBox IsWindowEnabled (hWnd)
MsgBox IsWindowVisible (hWnd)


'send keyboard commands to modeless dialog box
Dim wMsg As MSG
wMsg.hWnd = hWnd
wMsg.lParam = WM_TAB + WM_TAB + WM_TAB + WM_ENTER
'not sure if able line right?????

' hWnd As Long 'the window handle of the app
' message As Long 'the type of message (e.g. keydown)
' wParam As Long 'the key code
' lParam As Long 'not used
' time As Long 'time when message posted
' pt As POINTAPI 'coordinate of mouse pointer



If IsDialogMessage (hWnd, wMsg) = 0 Then
MsgBox "message not processed"
' 0 not message processed
Else
MsgBox "message processed"
' 1 message processed
End If


Regards

Justin
Jan 8 '07 #1
0 3900

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3425
by: Rikkert | last post by:
I can't get my custom-made modeless dialog box (Visual C++.net Win32) to respond to clicking the close button or pressing Alt-F4. I am using the IsDialogMessage to check if messages are for my dialog. However, my dialog procedure doesn't seem to get a WM_DESTROY message when I click the close button. Also, pressing Alt-F4 does not close my application when the dialog has focus (it does terminate when my main window or another child of...
1
4252
by: Carmine | last post by:
I'm currently writing a small program that churns on a repetitive task while displaying a progress & cancel modeless dialog. I've been having problems due to threadlocking, and I was wondering if anyone could give me some advice. Basically when I create the modeless dialog, I'm assuming that C# under the covers will be implicitly creating a new thread for the modeless dialog's message pump. Thus I protect the state determiners with a...
0
3195
by: Andrew | last post by:
I get a Null Reference Exception if I close a modeless form (that is, a form displayed using Show()) when a selection is made from a ComboxBox. If the form is modal (displayed using ShowDialog()) or the selection is made from, say, a ListBox, no exception is thrown. I have included a simple example below. The error message refers to Unsafe Native Methods, but the code is 100% managed. What is going on ? I am using C#.NET 2003, Standard...
2
3345
by: Legendary Pansy | last post by:
Hello, I'm trying to accomplish the impossible by trying to do something equivalent of this example found here http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as Starting with "Listing 2 - Changing the constructor of the modeless dialog to accept the parent object:" line and go onwards is what I'm trying to do Basically, there is the main form, and then there's the modeless form. I want the modeless form act like a modal form,...
1
2440
by: andrew | last post by:
Hi there, I'm having a problem with a modeless form in my app. I have a main form in my app and a socket that waits on data from a server (I use BeginReceive/EndReceive for that) and when I receive certain data from the server I want to create a new modeless form to show some of that data. But after receiving the data from the socket the modeless dialog does not appear (it seems to be receiving no windows message to update itself,...
2
3061
by: proit_123 | last post by:
I am working on a windows forms application and have the following requirement. · I need to display a modeless dialog from the main form. o This allows user to continue to work with the application. o For the sake of example, the user could launch the modeless dialog from Form A and navigate to a Form B in the main window. · When the modeless dialog is closed, I need to perform certain logic in the main form based on the form that is...
8
5465
by: proit_123 | last post by:
I am working on a windows forms application and have the following requirement. I have two projects in my application Project A and Project B. And Project A has the reference of Project B. I need to display a modeless dialog from the main form which is in Project A and the modeless dialog to be raised is in Project B. After closing the modeless dialog i need to pass a value from modeless dialog to the main form of Project A and also i...
0
1920
by: Sin Jeong-hun | last post by:
I've found that if a MessageBox (called by alert/confirm from Javascript) or a web page modeless dialog is popped up, I cannot call Navigate of the WebBrowser control. If I do, a COM exception occures. How can I disable javascript MessageBoxes or modeless dialogs? I disabled normal popup windows by adding e.Cancel=true at the browsers newwindow event. But I couldn't disable modeless dialog or javascript MessageBox. I tried to remove some...
3
5172
by: DoB | last post by:
What is the preferred way to refresh modeless dialogs? I am using the modeless dialog that shows a progress of a sequential process. The dialog class has nonvisual properties containg the progress status data and the dialog window has a timer and refreshes on every tick, but it does not seem to work correctly. Maybe I am doing it all wrong... what is a suggested way of programing this, provided that I want to have one general dialog...
0
9758
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10378
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9527
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7928
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4169
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.