|
Hi
I'm a Korean..
How to control the other program(for example, MS Word, Internet Explore etc...)'s scrollbar?
For example, when any button in my program is clicked,
my program want to know other program's scrollbar's "range"(or page, position) in client area.
how to???
|
|
|
|
|
Why on earth would you want to do *that* ?
If you enumerate the windows in some manner you can get the CWnd of another Window, then I presume you can call SetScrollPos, etc.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Hi Christian.
But how can i get CWnd pointer from other program ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Like this
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
char* h = new char[255];
GetWindowText(hwnd,h,255);
CString text(h);
long wl = GetWindowLong(hwnd,GWL_STYLE);
CArray<cstring, cstring="">* lb = (CArray<cstring, cstring="">*)lParam;
if (text.GetLength()>0 && IsWindowVisible(hwnd) &&
text != "Program Manager" && text != "Window Popper")
lb->Add(text);
return TRUE;
}
In my code, lParam is a CArray ( nowadays I would use a vector ), and I check the title of the window to see if it's one I want to ignore and if it's visible ( not doing the visibility check gives you a gazillion hidden windows ) and then pass the title into my list. Then I do this in my main code:
CArray<cstring, cstring=""> list;
EnumWindows(EnumWindowsProc, (long)&list);
and I can do this:
CWnd *pOtherWnd = CWnd::FindWindow(NULL, name);
if I find the Window I want ( for example, I might search for the first four letters of the title to be Word, but the next three not to be Pad ), then I get the CWnd by calling FindWindow. If I know for sure something is running and it's full title, then I can just go to this step.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Hello everybody,
Iam a newbie to ATL&ADOs.I am developing an ATL component which is to store some binary data in to a table using ADOs.I have a problem with storing of binary data. I don't know how to pass a parameter along with the SQL query, that's why i am using a sample ADO dll(adosamp) which is there in MSDN samples. I am getting the binary data (which may have null characters in between) thru a ptr to the buffer (char*) from another dll, after that i am using CComVariant to encapsulate that buffer (char*) & passing along with SQL query as a parameter. In the data that i am getting, the second character itself is null char (ASCII 0). I tried asigning the buffer's data (char*) in 2 ways
one is
passing the char* in constructor of CComVariant as CComVariant vt(buff)
and passing it's length as 195. if i do so it's taking the CComVartiant as of type VT_BSTR, the data getting stored is first 2 chars only (terminated with null char).
Second is
i have assigned the char* to "pcVal" field of CComVariant and set type of the CComVariant as VT_BYREF|VT_I1 & passing the length of buffer as 195. when i did so it's giving an error stating that
" Invalid string or length".
The data in CComVariant variable is there till the execute command.
How can i solve this problem & insert binary data in table(Access)?
Also tell me how to pass the buffer along with the SQL query as a parameter?
Thanks in Advance.
My e-mail id kgrajashekar@usa.net
|
|
|
|
|
convert the data bytes to text (inc 0 for zero's) and send them as a string into the db
ie, "hello world0It is a nice day0"
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Thanks for reply.
But Sorry lauren,
i didn't get u, what do u mean to say, please elobarate it.
|
|
|
|
|
well supposing you have binary data as follows:
765076004325600tsktsk00876
convert it to a ascii representation and in the sql statement that updates the db instead of using a numeric type to make the query text use a string type ... the db will convert it back to binary on the insert
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Couldn't he also use a SAFEARRAY of characters? That would preclude him from having to convert characters, and what if there's actually zero's in the blob of data?
I'm certainly no COM expert (far from it actually), but it seems a SAFEARRAY would be, ummm, safer.
|
|
|
|
|
awwwww ... where's the fun in that
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
I think he's past the "having fun" part...
|
|
|
|
|
Addressed below is a subset of your problem. Essentially, first, you are getting a byte array data typecast to char* and hence the trouble.
0. Use BT_BYREF|VT_UI1 *and* pbVal.
I bet this will work because VT_BYREF|VT_I1 maps to char*. (Meaning, a C-String to be ended at the first null character).
1. For another clean solution. (Divide the work between you and the dll guy):
- HGLOBAL hG = GlobalAlloc( GPTR, 192 );
- CreateStreamOnHGlobal gives you a pStream
- Use CComVariant::ReadFromStream
- Release pStream and hG correctly, later.
2. Or, you can hack like this:
::SysAllocByteLen(192 bytes) to allocate a BSTR yourself.
memcpy your data into BSTR
Encapsulate this BSTR into CComVariant.
Release SysFreeString the BSTR later
I think solution 0 above should solve your problem completely. If not, try 1. If 1 doesn't work, 2. also will not work, and it will be time to focus on ADO/Access interaction rather than CComVariant.
But, if ADO/Access is graceful enough about string lengths and all, I am betting, it's just the issue of data types, and solution 0 will take care of it.
-------
Nature, to be commanded, must be obeyed. (Francis Bacon)
Nature, to be apprehended, must be obeyed. (Ayn Rand)
|
|
|
|
|
On second thoughts...
Solution 2. above may not be suitable at all. Here's why. ADO/Access may not like a VARIANT of BSTR type for updates to a binary field in the DB. (Just check up about what data types it can take for TEXT, MEMO, etc. field types.)
-------
Nature, to be commanded, must be obeyed. (Francis Bacon)
Nature, to be apprehended, must be obeyed. (Ayn Rand)
|
|
|
|
|
Thank u very much Ajith for prompt reply. I will all the solutions.And inform u the result .Thanks once again.
K.G.RajaShekar
|
|
|
|
|
Hi All,
I am working with VC++(ATL COM AppWizard).How can I trim the leading and trailing spaces in a BSTR value ?
Thanx in advance for help !
Y.Yamini Devi .
|
|
|
|
|
hello,
im using winrunner to test an app and it is failing to find text in a list box when the fields are becomeing truncated. I wanted to overcome this by calling api functions to find the x y coordinates of focus rectangle as the desired item in the list has already been selected using the apps search function. With these i could move the mouse to those coordinates and continue the test.
Ive tried the following:
***********************************************************************************************
HWND Handel, ChildHandel; //Handels
POINT Pos;
Handel = FindWindow (NULL, "Fields"); //Get fields Window handel
ChildHandel = FindWindowEx (Handel, NULL, "STRHList", NULL); //Get List window
SetForegroundWindow(ChildHandel);
GetCaretPos (&Pos);
printf ("%d\n\n", Pos.x);
***********************************************************************************************
This prints out 0.
Is there any api function that will give my screen coordinates for the focus rectangle or the currently selected item in a list???
|
|
|
|
|
GetWindowRect ? What are you trying to do ? Did you copy and paste this code, and if so, I'm curious as to how your compiler accepts handel ?
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
By George I think he must have the classic version of the compiler!!!
|
|
|
|
|
Im trying to find the coordinates for a selected item in a list. The code i wrote there finds the handel for the list then sets it to the foreground. Then i try to get the caret position. As far as i know the focus rectangle is an invisible caret??? This code compiles and runs but obviously isnt giving me what i need. Im using visual C++ 6 is this a bad thing?
|
|
|
|
|
>Im trying to find the coordinates for a selected item in a list. The code i wrote there finds the handel for the list
> then sets it to the foreground. Then i try to get the caret position. As far as i know the focus rectangle is an
> invisible caret??? This code compiles and runs but obviously isnt giving me what i need. Im using visual C++ 6 is this
> a bad thing?
I'm at a loss to get what you're going to *do* with these co-ordinates. If you have a handle to the window, you can use GetWindowRect, like I said, but I'm not sure where you are headed,
VC++6 is fine, at least I hope so ( I use it for 10-16 hours a day )
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
lol ok i thought maby i could blame it on an old compiler.
I want to call this in a dll from winrunner and then use the co-ordinates to move the mouse above the field so i can drag and drop. There is a click on text function that works as long as the text isnt truncated and the rest ive got sorted. Obviously im not a developer but in testing ive done some simpler api calls succesfully, but this is a tough one.
Will GetWindowRect will give me the co-ords of the field list?? or the co-ords of the selected item? I need the latter which is why i started trying to find the focus rectangle in the first place or maby there is a way to find the hilite??
well out of my depth here
Will finding the caret give me the position of the input focus rectangle or is there a way GetWindowRect will do it???
Thanks for trying to understand what im on about
|
|
|
|
|
A minor point - you're misspelling the word "Handle".
In code I'm working on now, someone misspelled the word "Delimiter" as "Delimeter". We all know that a deli-meter is a unit of (length) measurment commonly used in restaraunts that produce submarine sandwiches, and is the overall length of a deli sandwich after it is disassembled and its components are laid end-to-end. When converted to standard measurements, it equals to about 33-1/2 inches.
|
|
|
|
|
How would I open a connection to an FTP server such that I could send actual
commands to the server (ex: LIST, etc) and view the actual responses the
server gives (Welcome messages, etc).
I know how to use the CFtpConnection to do basic FTP stuff, but I don't
think it does this.
Anyone have any ideas?
Adam
cabadam@houston.rr.com
|
|
|
|
|
ummmm you could just open a socket @ port 21 and send the commands thru as most full-blown ftp programs do ... you'll need the rfc for the ftp protocol and all that and then its not too difficult ... i dont know if there is any windows source code available to show it but i'm sure there would be some unix stuff around that wouldn't be too different in the basics of sockets etc
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Ok, still problem though:
I am using a derived CAsyncSocket (CFtpSocket) for initial connection. (Tried this with both CSocket and CAsyncSocket)
When I call the Connect(host,port), it returns true, giving me the initial socket connection. However, at that point, shouldn't I get a welcome message? I have been comparing what my program gives to what CuteFTP gives, and it says:
STATUS:> Connect: Monday 17:10:21 05-07-2001
STATUS:> Connecting to ftp.angelfire.com
STATUS:> Connecting to ftp.angelfire.com (ip = 216.33.20.80)
STATUS:> Socket connected. Waiting for welcome message...
220 Hi! Welcome to Angelfire's NEW FTP.
But in my program I never get that welcome message. It just stops after the socket connects. I have the OnReceive() overwritten and it SHOULD call that when I get the welcome message right? Or am I missing something? OnReceive is never getting called in my program.
Adam
cabadam@houston.rr.com
|
|
|
|