|
i want i program that will tell me what is the value in the calculator(for example) text box. the UI shouls be output only.
the way i thought of doing this was to go through all the process and when i reach to right one check it's window handle's. but i don't how to get the process's list and how to get the handles from the process.
|
|
|
|
|
For start you can use EnumWindows for get handle for each process and for more functions that you will be help them see Process and Thread Functions[^].
|
|
|
|
|
YS8888 wrote: i want i program that will tell me what is the value in the calculator(for example) text box.
Or maybe a password text box??
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think its not possible for all programs.
|
|
|
|
|
YS8888 wrote: I need to write a program that needs to "steel"
Since your intentions are so honest, I'm going to help you: have a look at EnumWindows [^] function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Try something like this:
#include "stdafx.h"
#include <tchar.h>
#include <malloc.h>
#include <windows.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
HWND hwndCalc = FindWindow(_T("SciCalc"), _T("Calculator"));
if (hwndCalc == NULL)
{
cerr << "Couldn't find the Calculator window!" << endl;
return -1;
}
HWND hwndEdit = FindWindowEx(hwndCalc, NULL, _T("Edit"), NULL);
if (hwndEdit == NULL)
{
cerr << "Couldn't find the Calculator's edit control!" << endl;
return -2;
}
int len = SendMessage(hwndEdit, WM_GETTEXTLENGTH, 0, 0);
if (len == 0)
{
cerr << "Text empty?!?" << endl;
return -3;
}
LPTSTR pBuffer = static_cast<LPTSTR>(_alloca((len+1)*sizeof(TCHAR)));
int res = SendMessage(hwndEdit, WM_GETTEXT, len+1, reinterpret_cast<LPARAM>(pBuffer));
if (res == 0)
{
cerr << "Text empty?!?" << endl;
return -4;
}
#ifdef UNICODE
wcout << _T("Calculator's result: ") << pBuffer << endl;
#else
cout << _T("Calculator's result: ") << pBuffer << endl;
#endif
return 0;
}
It's a console application.
Steve
|
|
|
|
|
Hi i am quite new in MFC but know C++ programing and done work in VC 6 using win32 console application now switching to MFC. So please tell me how can i add images button? How can i change the colors of dialouge boxes. I shall be very thankfull to you.
Regards:
Xohaib Shirani
|
|
|
|
|
CImage m;
m.Load(_T("c:\\1.jpg"));
m_Button.SetBitmap(m.detach());
but if you want to use of bitmaps you can use of LoadImage.
|
|
|
|
|
Dear i tell you that i am quite new in MFC so plz guide me where i have to put this code
CImage m;
m.Load(_T("c:\\1.jpg"));
m_Button.SetBitmap(m.detach());
??
Regards:
Xohaib Shirani
|
|
|
|
|
So you need to more info,Ok.
First you must load your image with LoadImage or CImage class or GDI+,...
After load your image you will be have a handle to that image file then you can use of this handle at control that you want to use it.
For example I guess you have a Static control and you want to insertimage to it:
//(1)Declare a variable of CImage
#include "atlImage.h"
CImage m;
//(2) load image file (you need to path of file
m.Load(_T("c:\\1.jpg"));
//(3) set control to that image file
m_Static.SetBitmap(m.detach());
|
|
|
|
|
Do you have any idea to change the colors of dialoge boxes??
I ask too much question?? Hmmm... Sory bro need to learn...
Regards:
Xohaib Shirani
|
|
|
|
|
Yeah I have an Idea WM_CTLCOLOR is your answer.
|
|
|
|
|
Start by browsing this website. I know there are multiple articles on fancy buttons, and some on changing backgrounds for all sorts of things.
Expand the "desktop development" part on the left, the look under "button controls", and "dialog and windows".
It will take you a while to find what you are looking for, but you'll trip over many other good things along the way.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
Hi
I am building my tool in VC++ 2008 and it is non /clr based. I want the code that converts string to char* and it should be non clr based.
I set project property "Common language runtime" as "No Common language runtime".
http://support.microsoft.com/kb/311259[^]
This link provides me solution to my problem but for that i have to set project property "Common language runtime" as a "Common language runtime support" which i don't want. Because if i change it gives me an error
fatal error C1113: #using failed on 'h:\bipin\b.e\kpit proj\copy control\temp\dllproject\debug\dllproject.lib'
Here is my code
string snos;
c1.ReadPhysicalDriveInNTWithZeroRights(snos);
fuction reads hard disk serial number and stores it into "snos".
Thanking you.
|
|
|
|
|
I think you asked this question and delete your question,right(one hours ago)?
|
|
|
|
|
I though ur not getting it. so i deleted my previous question.
you want what exactly ?
convert a C++ string (std::string) to a C style string (char*) ?
ya toxcct i want that.
|
|
|
|
|
|
|
the std::string class has a c_str() function which returns a char*...
std::string str = "Hello World";
char psz[20] = {0};
::strcpy(str.c_str(), psz);
|
|
|
|
|
so you think deleting your previous post and reposting it exactly the same again will change something ?
just wondering : why are you insisting that much about the CLR thing ?
you want what exactly ?
convert a C++ string (std::string) to a C style string (char*) ?
or you want to get the HDD serial number anyway ?
BTW, where are you taking this function from ?
|
|
|
|
|
toxcct wrote: just wondering : why are you insisting that much about the CLR thing ?
Maybe because searching MSDN for string returns tons of System.String links but almost no std::string links.
MS is pushing us heavily in the direction of .NET.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
hum, yes, probably, but i don't read the MSDN, i just KNOW it ! lol
|
|
|
|
|
I want to convert a char array containing embedded NULL(/0) chars to BSTR.
eg cArr['1','2','NULL','3','NULL','4','5','NULL'].
Is it possible to convert it to bstr without losing anything.
So the _bstr_t variable will contain "12NULL3NULL45NULL"
|
|
|
|
|
This [^] looks promising.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You are correct, Seems to work:
BSTR MyBstr = ::SysAllocStringByteLen(strVar, strSize);
_bstr_t bstrSend(MyBstr, true);
|
|
|
|