Hi,
I'm a C++-Programmer and want to subclass the Edit used to write a
SQL-Query in Access. The edit is of the special Access class OKttbx.
Everything works, I injected a DLL into the Access-Process and the
subclassing works but I can't get the Windowtext of the control...I
tried the WM_GETTEXT message but it seems that Microsoft uses another
way to get the text the user typed in.
Has somebody an idea how I can get this to work?
mfg Steven 10 3970
Hi Steven,
here is an example using GetWIndowText, which just calls WM_GETTEXT. The
important point here is that the OQry window control(s) are lightweight.
When the window does not have the focus, its child OKttbx window
contains nothing. Only when the OQry window has the focus, and it is in
SQL View, are you able to get at the SQL text contents. The child OKttbx
window is shared with SQL Design, SQL View and SQL Datasheet views.
This code is placed behind the Click event of a CommandButton control
named "cmdQuery". It assumes a saved Query with the name of "1" and a
TextBox control with a name of "Text3".
Private Sub cmdQuery_Click( )
On Error GoTo Err_cmdQuery_Cl ick
Dim lngRet As Long
Dim hWndMDI As Long
Dim hWndOQry As Long
Dim hWndOKttbx As Long
Dim s As String
' Open a Query
DoCmd.OpenQuery "1", acViewNormal
DoCmd.RunComman d acCmdSQLView
DoEvents
' The OQry Window is a child of the MDI Client window
' find MDIClient first.
hWndMDI = FindWindowEx(Ap plication.hWndA ccessApp, 0&, "MDIClient" ,
vbNullString)
' Find the OQry Window
hWndOQry = FindWindowEx(hW ndMDI, 0&, "OQry", vbNullString)
If hWndOQry = 0 Then
MsgBox "The SQL View Window is not open.", vbCritical, "Critical
Error"
Exit Sub
End If
' Find the window of class OKttbx
hWndOKttbx = FindWindowEx(hW ndOQry, 0&, "OKttbx", vbNullString)
' Get the Text of the SQL Design window
s = Space(512)
lngRet = GetWindowText(h WndOKttbx, s, 256)
Debug.Print "S:" & s & Time
Me.Text3.Value = s
Exit_cmdQuery_C lick:
Exit Sub
Err_cmdQuery_Cl ick:
MsgBox Err.Description
Resume Exit_cmdQuery_C lick
End Sub
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"fotzor" <st******@gmx.d e> wrote in message
news:44******** *************** ***@posting.goo gle.com... Hi, I'm a C++-Programmer and want to subclass the Edit used to write a SQL-Query in Access. The edit is of the special Access class OKttbx. Everything works, I injected a DLL into the Access-Process and the subclassing works but I can't get the Windowtext of the control...I tried the WM_GETTEXT message but it seems that Microsoft uses another way to get the text the user typed in. Has somebody an idea how I can get this to work?
mfg Steven
On May 16 2004, 06:17 am, st******@gmx.de (fotzor) wrote in
news:44******** *************** ***@posting.goo gle.com: I'm a C++-Programmer and want to subclass the Edit used to write a SQL-Query in Access. The edit is of the special Access class OKttbx. Everything works, I injected a DLL into the Access-Process and the subclassing works but I can't get the Windowtext of the control...I tried the WM_GETTEXT message but it seems that Microsoft uses another way to get the text the user typed in. Has somebody an idea how I can get this to work?
SendMessage with WM_GETTEXT works for me. If VB source helps you any, take
a look at WinTree from http://www.users.cloud9.net/~dfurman/code.htm. In
the cWindow class, look at the WindowText property. You may be doing this
already, but you need first to call SendMessage with the WM_GETTEXTLENGT H
parameter to get the length of the text, then use WM_GETTEXT.
--
remove a 9 to reply by email
Well, it works - almost!
It works only before I subclass. When I Execute the following code in
the handler of WM_PAINT (where I actually need the text) it shows me
stuff (like before). I hope the code is self-explanatory
void OnPaint(HWND hWnd)
{
SetFocus(GetPar ent(hWnd));
int len = GetWindowTextLe ngth(hWnd);
char* pchText = (char*) malloc(len + 1);
if (pchText) {
GetWindowText(h Wnd, pchText, len);
}
... Print the text
}
I think the problem is that the edit I subclassed is the child of OQry
and therefore has the input focus when OQry should have it. But when I
test immediately after SetFocus() whether OQry has the Focus, it
actually has it...strange!
do you have another idea how to solve this? do you know where (in
memory) OQry saves the text? and why wanted the ms programmers this to
be such complicated?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Why are you setting focus to the parent? If this Paint handler function
is for the subclassed OKttbx then as I mentioned the focus should stay
with OKttbx control.
Is this an ActiveX control you are creating in VC?
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"steven weiss" <st******@gmx.d e> wrote in message
news:40******** *************@n ews.frii.net... Well, it works - almost! It works only before I subclass. When I Execute the following code in the handler of WM_PAINT (where I actually need the text) it shows me stuff (like before). I hope the code is self-explanatory
void OnPaint(HWND hWnd) { SetFocus(GetPar ent(hWnd));
int len = GetWindowTextLe ngth(hWnd); char* pchText = (char*) malloc(len + 1); if (pchText) { GetWindowText(h Wnd, pchText, len); }
... Print the text }
I think the problem is that the edit I subclassed is the child of OQry and therefore has the input focus when OQry should have it. But when I test immediately after SetFocus() whether OQry has the Focus, it actually has it...strange!
do you have another idea how to solve this? do you know where (in memory) OQry saves the text? and why wanted the ms programmers this to be such complicated?
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Hi Dimitry!
Answering the original question in this thread gave me an excuse to post
this: http://www.lebans.com/addsqlcomments.htm
NEW - May 16/2004 A2KAddSQLCommen ts.zip is an MDB containing functions
to:
1) To allow the saving of Comments in the SQL View window.
2) To allow the saving/restoration of Comments in the SQL View window.
Here is the A97 version:A97AddS QLComments.zip
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Dimitri Furman" <df*****@cloud9 9.net> wrote in message
news:Xn******** *************** *****@127.0.0.1 ... On May 16 2004, 06:17 am, st******@gmx.de (fotzor) wrote in news:44******** *************** ***@posting.goo gle.com:
I'm a C++-Programmer and want to subclass the Edit used to write a SQL-Query in Access. The edit is of the special Access class OKttbx. Everything works, I injected a DLL into the Access-Process and the subclassing works but I can't get the Windowtext of the control...I tried the WM_GETTEXT message but it seems that Microsoft uses
another way to get the text the user typed in. Has somebody an idea how I can get this to work? SendMessage with WM_GETTEXT works for me. If VB source helps you any,
take a look at WinTree from http://www.users.cloud9.net/~dfurman/code.htm.
In the cWindow class, look at the WindowText property. You may be doing
this already, but you need first to call SendMessage with the
WM_GETTEXTLENGT H parameter to get the length of the text, then use WM_GETTEXT.
-- remove a 9 to reply by email
On May 16 2004, 03:34 pm, "Stephen Lebans" <ForEmailGotoMy .WebSite.- WW************* ***@linvalid.co m> wrote in
news:vn******** *************@u rsa-nb00s0.nbnet.nb .ca: Hi Dimitry! Answering the original question in this thread gave me an excuse to post this: http://www.lebans.com/addsqlcomments.htm NEW - May 16/2004 A2KAddSQLCommen ts.zip is an MDB containing functions to:
1) To allow the saving of Comments in the SQL View window. 2) To allow the saving/restoration of Comments in the SQL View window.
Hi Stephen,
Very nice, and long needed too!
One possible improvement would be to look for the last ";" in the SQL
string, not the first one, because you may have a subquery which also ends
with ";". A user may also enter ";" in the comments, so I guess you should
skip everything after "/Comment" when looking for the last ";". It is also
possible to enter parsable SQL in the query SQL window that has no
semicolons anywhere in it (Access usually adds one silently to the end of
the string, but only when you run or save the query).
--
remove a 9 to reply by email
Thanks for the advice Dimitri. I will implement your suggestions as you
mentioned to allow for subqueries.
The current code will only work for saved queries as it relies on the
SQL View window's caption to identify and store/restore any Comments.
:-)
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Dimitri Furman" <df*****@cloud9 9.net> wrote in message
news:Xn******** *************** *****@127.0.0.1 ... On May 16 2004, 03:34 pm, "Stephen Lebans" <ForEmailGotoMy .WebSite.- WW************* ***@linvalid.co m> wrote in news:vn******** *************@u rsa-nb00s0.nbnet.nb .ca:
Hi Dimitry! Answering the original question in this thread gave me an excuse to
post this: http://www.lebans.com/addsqlcomments.htm NEW - May 16/2004 A2KAddSQLCommen ts.zip is an MDB containing
functions to:
1) To allow the saving of Comments in the SQL View window. 2) To allow the saving/restoration of Comments in the SQL View
window. Hi Stephen,
Very nice, and long needed too!
One possible improvement would be to look for the last ";" in the SQL string, not the first one, because you may have a subquery which also
ends with ";". A user may also enter ";" in the comments, so I guess you
should skip everything after "/Comment" when looking for the last ";". It is
also possible to enter parsable SQL in the query SQL window that has no semicolons anywhere in it (Access usually adds one silently to the end
of the string, but only when you run or save the query).
-- remove a 9 to reply by email
>> Why are you setting focus to the parent?
I gave it a try because I wasn't able to get the Window text in the
WM_PAINT-handler Is this an ActiveX control you are creating in VC?
No, it's a DLL which gets into the Access process and subclasses the
SQL-Query-Window to draw bigger letters. It's very annoying to be not
able to change the font size...
@Stephen
Your example didn't help much. I tested if OKttbx has the focus (indeed
it has) and wanted to get the Windowtext with GetWindowText (like you)
but I get stuff...
Do you have any Suggestions and ideas else?
Thanks anyway for your help, I think I'm on the right path now :-)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I remember a couple of years ago using WM_SETFONT to try to change the
Font in the SQL View window. Access does not bother to use the actual
SQL View window's current Font metrics as it refuses to believe that the
System font is not selected into the window. So overriding the Paint
proc would not be enough. You would have to handle the keyboard
interface as well.
Please let the group know how you make out. A2003 finally has the
functionality to allow the user to select the SQL View window Font size.
For A2K2 or lower, most users would enjoy using your solution.
--
HTH
Stephen Lebans http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"steven weiss" <st******@gmx.d e> wrote in message
news:40******** *************@n ews.frii.net... Why are you setting focus to the parent? I gave it a try because I wasn't able to get the Window text in the WM_PAINT-handler
Is this an ActiveX control you are creating in VC? No, it's a DLL which gets into the Access process and subclasses the SQL-Query-Window to draw bigger letters. It's very annoying to be not able to change the font size...
@Stephen Your example didn't help much. I tested if OKttbx has the focus
(indeed it has) and wanted to get the Windowtext with GetWindowText (like you) but I get stuff...
Do you have any Suggestions and ideas else? Thanks anyway for your help, I think I'm on the right path now :-) *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: magician |
last post by:
Hi
Im having trouble setting the bold and 'not' bold properties in a rich text
control.
All the text in the control is entered through code and the bold property is
different for different sections.
I am using the selstart and sellength to set the selection then either
selbold=true or false to set the bold.
I have debug.printed the selections and true false to see if it is getting
the correct selections and true or false.. but it is no...
|
by: MisterJ |
last post by:
Here is the situation:
I am attempting to reposition a rich text control within a frame in a
running vb6 program.
What I want to do is to click on the text box then drag it to a new
position.
What happens is that the text box has a mind of its own and goes
elsewhere.
|
by: none |
last post by:
Hi,
I wrote a program for work that processed and formatted some
collected text data in a Tkinter based GUI display. I've found that as
my data files get longer (a few thousand lines), there seems to be a
real lag when it comes to clearing or updating the Text control, enough
so that the program just isn't useful. I poked around some and saw
several people mention that is was a known issue with Tkinter.
I'm trying to decide what is the...
|
by: NancyASAP |
last post by:
In case anyone hasn't seen this problem, just sharing the info....
I created a dotnet 1.1 page with a literal control. I used a
streamreader to open a text file to fill the control. I filled the
control on page load.
When viewing the page in IE 6.0, sometimes the literal control did not
display all of the text. Refreshing the page (via browser refresh
button) would cause random results; sometimes more text, sometimes less
(whole...
|
by: Gwin |
last post by:
I am programming a client service dbase in access 2000 for a
non-profit health clinic.
I want to create a navigation menu that can show varying numbers of
command buttons with varying captions, driven by data from a table.
1. First, the user selects a "client" by code. This opens a
navigation form which offers command buttons for each of the services
the client is enrolled in, e.g., nutrition, pre-natal care, drug
treatment, etc. ...
| |
by: David Davis |
last post by:
Woll2Woll has a product for Delphi called Infopower which has a rtf control
with a built-in word processor. Does anyone know of a third party control
that has the same capabilities. I don't have the experience in Dot Net to
write one myself.
--
Thanks
David Davis
|
by: tlyczko |
last post by:
Hello,
I'm experimenting with Stephen Lebans' Rich Text Control for doing RTF
data entry into a memo field.
I imported the table, form, toobar, and modules from the A2k version
into an A2k3 DB. Then I edited a sample table record using the sample
form provided, then closed Access.
Then I could not re-open the MDB containing these items, nor any other
|
by: (PeteCresswell) |
last post by:
Got a text control that where .Locked = True.
I have the text blue and underlined to simulate a clickable link on a web page.
If the user clicks on that field, I open up a window that shows the detail
behind that text.
Only problem is that then the user moves the mouse pointer over the field, the
mouse pointer turns into an insertion point.
|
by: ozzy66 |
last post by:
Hiho NG,
I've created a tool (tray application) like "keytext" or "shortcut"
that is a little tool where you can store text components which you can
call from any running app. Such a stored text will then be written on
any focused text control.
So far, so good. It works quite well. The tool is firstly hidden and
can be called by hotkey (F11). A list of stored text components appears
and the user can select one (or add new or change,...
|
by: elastreto |
last post by:
Hello,
I have been trying, so far in vain, to hide the label and text control in a form when the text control is empty/null.
I have looked at past postings and tried the code below, however I am getting Run-Time Error 438, stating that the object doesn’t support this property or method.
I don't know if I am writing the code to the wrong place or if I have an error in the code itself. Any help is appreciated!!
(I am running Access...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |