|
Yes, the executable is running and I know the full path name
|
|
|
|
|
To find the window Handle you need to know which window you are looking for.Windows are basically running objects in memory. At File level it make no sense.So windows classname or caption is essential for finding the handle.you can use FindWindow(...) API to get handle..
Jast have a Look on MS SPY++ utlity. Using that you can figure out classnames /captions and also handles
|
|
|
|
|
olivier wrote:
knowing only the executable path
Has pretty nothing to do with the window itself. You'll have to know something about the Window name, or classes. Have a look at EnumWindows() .
~RaGE();
|
|
|
|
|
Hello,
I have a function that receives a (void *) parameter:
GetSizeOfTypeAndDoSomeOtherLargeStuffWithIt(void *pParam);
I use this function passing a pointer to all sort of numerical variables in order to process them without overloading that function and having to maintain a lot of overloaded functions... (I can pass from &bool to &double variables tot that function).
when I do sizeof(pParam); I always get the size of the void * and if I would be passing a char I would like to get the size of the char and if I would be passing an int I'd like to get the size of an int ...
Is this possible?
Thank you in advance...
|
|
|
|
|
Joan Murt wrote:
when I do sizeof(pParam); I always get the size of the void *
Of course. Anything else would be such a serious compiler bug that the compiler would be virtually useless.
I would like to get the size of the char and if I would be passing an int I'd like to get the size of an int...
Is this possible?
No, the kind of polymorphism you are interested in is not possible. You might consider adding a type argument also, or maybe have a look at templates.
|
|
|
|
|
Why aren't you using a template function?
eg:
<br />
#include<iostream><br />
<br />
using namespace std;<br />
<br />
template<class T> void Function(T Var)<br />
{<br />
cout << "Size is " << sizeof(Var) << ", value is " << Var << endl;<br />
}<br />
<br />
int main(void)<br />
{<br />
int i = 3;<br />
double d = 5.56;<br />
Function(i);<br />
Function(d);<br />
<br />
return 0;<br />
}
The output being:
<br />
Size is 4, value is 3<br />
Size is 8, value is 5.56<br />
--
Ian Darling
|
|
|
|
|
First of all thank you,
I'm trying in a little program what you've told me, but I'm getting this error in each call:
C:\Projectes\TAM i Àmbit general\00 - Inconsistència i Proves\ObtenirDimensionsPunterVoid\ObtenirDimensionsPunterVoidDlg.cpp(118) : error C2893: Failed to specialize function template 'void __thiscall CObtenirDimensionsPunterVoidDlg::calcula(T *)'
With the following template arguments:
'bool'
what can I do to solve it?
the code I use is:
CPP FILE:
template<class T> void CObtenirDimensionsPunterVoidDlg::calcula(T *p)
{
UpdateData();
this->m_iAntic = sizeof(p) * this->m_iFactor;
UpdateData(FALSE);
}
void CObtenirDimensionsPunterVoidDlg::OnButton9()
{
bool b = false;
calcula(&b);
}
HEADER FILE:
public:
template<class T> void calcula(T *p);
NOTES:
1. I need to pass the parameter by reference... (I must be able to read it's value after the function has finished... this is why I've placed the *.).
|
|
|
|
|
Well, for starters I think you are taking the size of the pointer type, and not the actual type (ie, sizeof(p) is returning the size of a T* which is probably always going to be 4 bytes, not the size of a T, which for a bool in VC++, is probably 1 byte. You can resolve this by either passing by value and returning any changed value (see 1), or passing by reference as opposed to by pointer (see 2)
1:
<br />
template <class T> T CObtDPVD::calcula(T p)<br />
and then using:
<br />
bool b=false;<br />
b = calcula(b);<br />
2:
<br />
template <class T> void CObtPVD::calculat(T &p)<br />
and then using:
<br />
bool b=false;<br />
calcula(b);<br />
As for the compiler error, I'm not sure where that's come from.
HTH
--
Ian Darling
|
|
|
|
|
Hello,
it seems that I cannot declare the function inside the class...
I've changed this:
template<class T> void CObtenirDimensionsPunterVoidDlg::calcula(T& p)
to this:
template<class T> void CObtenirDimensionsPunterVoidDlg::calcula(T& p)
and I've commented the declaration inside the header file...
in this way this seems (I've not been able to full test it) to be working...
but I need to place it inside the class...
any idea?
Thank you in advance...
|
|
|
|
|
Unfortunately, this is one of the limitations of the Visual C++ compiler as it currently stands - all template declarations and definitions have to be in the same file. One way around this is to declare a small template helper class or function in the cpp file that does the necessary calculation work, instead of a member function.
So in your .cpp file you would have something similar to:
<br />
template<class T> int calcula(T &p, int iFactor)<br />
{<br />
return sizeof(p) * iFactor;<br />
}<br />
<br />
void CObtenirDimensionsPunterVoidDlg::OnButton9() <br />
{<br />
bool b = false;<br />
UpdateData();<br />
m_iAntir = calcula(b, m_iFactor);<br />
UpdateData(FALSE);<br />
}<br />
I hope this ilustrates my point well enough.
--
Ian Darling
|
|
|
|
|
Hello,
I don't want to continue annoying you with my questions and moreover after taking a look at my code again, I would like to be able to use a template function as a class member...
Then I will place a new question to the forum.
Thank you for your help.
|
|
|
|
|
Templates need to be defined in the Header-file.
The compiler needs to know what code to produce whenever the template is used.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi All !
Like in the old driver installation apps , I'd like to insert or remove a REM in a dos batch file, i.e. to insert/remove a string in the middle of a file.
What is the best way to do it ?
~RaGE();
|
|
|
|
|
Just read all lines of the file in a memory, like in a list of CString s. Then parse every line and add the REM or remove it.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
OK, that's what I was doing up to now, but I thought there was a way to do it directly in the file.
Thank you very much for your help.
~RaGE();
|
|
|
|
|
Is it possible to modify the Exports Tables from PE files? How?
VikramS
|
|
|
|
|
OBS!<br />
No MFC sh*t now! Okay? :)
How can I keep the background color white when I have a read-only edit box?
I do my painting with SetBkColor() in WM_CTLCOLOREDIT.
But that may be wrong? Or...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
You should probably have to derivate your own class from CEdit, and try to catch the reflection of WM_CTLCOLOR (ON_WM_CTLCOLOR_REFLECT() ), then implement HBRUSH CMyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
HTH,
K.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
KaЯl wrote:
CEdit
But KaЯl, what did I said in the beginning of my message?
"No MFC sh*t now"
Do you know how to cath the reflection in pure Win32?
Thank you anyway!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
, my apologizes, I wasn't careful enough.
In MFC sources:
#define ON_WM_CTLCOLOR_REFLECT() \<br />
{ WM_CTLCOLOR+WM_REFLECT_BASE, 0, 0, 0, AfxSig_hDw, \<br />
(AFX_PMSG)(AFX_PMSGW)(HBRUSH (AFX_MSG_CALL CWnd::*)(CDC*, UINT))CtlColor },
I have really few experience of pure Win32 programming, it is possible to catch in your message loop the one corresponding to (WM_CTLCOLOR+WM_REFLECT_BASE), for the window with
the HWND of the Edit control ?
Perhaps this page [^] may help you.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
Intercept WM_CTLCOLORSTATIC in the window procedure of the control's parent.
rechi
|
|
|
|
|
Woohoo!
Danke schön!
BUT!
The whole edit box doesn't get white!
My edit is 300 in height and if I have not put text on all lines there will be grey color on lines where I don't have text. Daoh... it's difficult to explain... my egnlish just went broken!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Call
SetBkColor((HDC)wParam, BACKGROUND_COLOR); before returning from the handler of WM_CTLCOLORSTATIC .
rechi
|
|
|
|
|
Bogdan Rechi wrote:
before returning from the handler of WM_CTLCOLORSTATIC
Huh?
What do you mean?
I do like this:
....
case WM_CTLCOLORSTATIC:
if((HWND)lParam == myEdit)
SetBkColor((HDC)wParam, RGB(255,255,255));
break;
....
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Do it like this:
case WM_CTLCOLORSTATIC:
if((HWND)lParam == myEdit)
{
SetBkColor((HDC)wParam, RGB(255,255,255));
return (BOOL)GetStockObject(WHITE_BRUSH);
}
rechi
|
|
|
|