|
I get the error "type unexpected". for fmod prefixes. What should I do?
|
|
|
|
|
Hello, I am trying to interact dynamically with a 3rd party application dialog. This dialog has the usual OK and CANCEL buttons and an edit box. I want to be able to set the text in this edit box. I have managed to enumerate the handle of the dialog, but can't see how to find the ID of the edit box in order to get it's handle and thereby set the text. Perhaps someone can point me in the right direction !!
Doug
|
|
|
|
|
You can use the call GetWindow, and use the GW_CHILD flag to start out with. Then test for the type of class of that window with a call to GetClassName. You are looking for the "EDIT" class. When you find a window whose class matches that criteria, you will have the handle to the Edit control.
After testing each handle, if you have not found the correct window, then call for the next child window of the dialog, using the child window handle from the previous call to GetWindow, and this time use the GW_HWNDNEXT flag.
Ex.
HINSTANCE hInst;
HWND hDlg;
TCHAR className[_MAX_PATH];
...
HWND hChildWnd = ::GetWindow(hDlg, GW_CHILD);
while (hChildWnd != NULL)
{
WNDCLASS wndClass;
::GetClassInfo(hChildWnd, className, sizeof(className));
if (0 == ::_tcscmp(className, _T("EDIT"))
{
// This is the window handle that you want.
// Record the window handle here or do your special processing.
...
break;
}
hChildWnd = ::GetWindow(hChildWnd, GW_HWNDNEXT);
}
If there are more than one edit controls on the dialog things get a bit trickier.
You should look at the tool Spy++ that came with Visual Studio, it will allow you to peek at all of the important data regarding the windows, its class type, id etc.
|
|
|
|
|
Hi Paul, What a brilliantly comprehensive answer !
Very many thanks !
Doug
|
|
|
|
|
Hello all;
I write a simple program to calculate quadratic equation with function in c.
<br />
#include <stdio.h><br />
#include <math.h><br />
float solver(float a,float b, float c){<br />
float delta,x1,x2;<br />
delta=(b*b)-4*a*c;<br />
x1=(-b+sqrt(delta))/2*a;<br />
x2=(-b-sqrt(delta))/2*a;<br />
return(x1,x2);<br />
}<br />
void main(){<br />
float a,b,c,d; <br />
printf("a = ");<br />
scanf("%f", &a);<br />
printf("b = ");<br />
scanf("%f", &b);<br />
printf("c = ");<br />
scanf("%f", &c);<br />
printf("%f\n%f",solver(a,b,c));<br />
<br />
}
the result for a=1,b=2,a=1 is
-1.00000
0.00000
and for any other numbers the second result is 0.00000
Where is the problem.
Thanks anyone help me.
|
|
|
|
|
hasani2007 wrote: printf("%f\n%f",solver(a,b,c));
-here you try to print 2 float values but feed printf only with one.
hasani2007 wrote: return(x1,x2);
-this is not the way to return 2 values from a function (i guess this is what you are tryin to do), use output parameters, a struct, global variables, ..., e.g like:
void solver(float a,float b, float c, float &outX1, float &outX2){
...
outX1 = x1;
outX2 = x2;
}
...
float x1, x2;
solver(a,b,c,x1,x2)
printf("%f\n%f",x1,x2);
...
or
struct result
{
float x1;
float x2;
};
result solver(float a,float b, float c){
...
result res;
res.x1 = x1;
res.x2 = x2;
return res;
}
...
result res = solver(a,b,c);
printf("%f\n%f",res.x1,res.x2);
...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I'm not an expert in the details of C/C++, but the solver function definition shows a float should be returned and it appears you're trying to return a tuple.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Your program to calculate quadratic equations with .
Input MUST have the format:
AX2 + BX + C = 0
EXAMPLE: input the equation
2X2 + 4X -30 = 0 as:
A= 2 B= 4 C= -30
The answers should be 3 and -5.
x1=3
x2=-5
#include <stdio.h>
#include <math.h>
float x1,x2;
bool solver(float a,float b, float c)
{
float delta = sqrt( (b*b) - (4*a*c) );
if (!a) return false;
x1 = ( -b + delta)/(2*a);
x2 = ( -b - delta)/(2*a);
return true;
}
int main()
{
float a=2,
b=4,
c=-30;
if ( solver(a, b ,c) ) printf("x1=%f\nx2=%f\n",x1,x2);
return 0;
}
..
|
|
|
|
|
Please, don't give such a bad solution!!!
I've adjusted it to avoid global variables:
#include <stdio.h>
#include <math.h>
bool solver(float a,float b, float c, float &x1, float &x2)
{
float delta = sqrt( (b*b) - (4*a*c) );
if (!a) return false;
x1 = ( -b + delta)/(2*a);
x2 = ( -b - delta)/(2*a);
return true;
}
int main()
{
float a=2,
b=4,
c=-30;
float x1,x2;
if ( solver(a, b ,c, x1, x2) ) printf("x1=%f\nx2=%f\n",x1,x2);
return 0;
}
|
|
|
|
|
|
I want to add a comment to Code-o-mat's reply. The value of the expression (x1,x2) is the value of x2. You were trying to return two float values, however, you did not pay attention to the "," operator, and thought that (x1,x2) represents the two value you wanted to return. The compiler actually returned just the value of x2. Please read the documentation of C/C++ for the operator ",".
|
|
|
|
|
At 5:35 on the 13th of May 2010, AbhiHcl wrote:
>>>
>>> Hi,
>>>
>>> Can I use single button for more than one behaviour.
>>> For example one button is devide into 2 parts,
>>> If I click on first part minus operation should be performed
>>> and click on second part + opeartion should be performed.
>>>
>>>
Yes you can use one single button for more than one behaviour.
Here is how.
If you have the coordinates of a point in device coordinates
and want to find the corresponding position in logcal view -
use CDC::DPtoLP to convert the device coordinates to logcal coordinates.
Call on OnPrepareDC first to set the mapping mode and factor.
For example: Here is a WM_LEFTBUTTONDOWN handler that performs a simple hit test
to determine whether the click point lies in the upper or lower half of the logcal view.
CPoint objects passed to OnLButtonDown and other mouse message handlers
always contain device coordinates so conversion is essential.
void CMyView::OnLButtonDown(UINT nFlags, CPoint Point)
{
CPoint pos=Point;
CClientDC dc (this);
OnPrepareDC(&dc);
dc.DPtoLP(&pos);
CSize size=GetTotalSize();
if(::abs( pos.y ) < (size.cy/2) )
{
}
else
{
}
}
...
|
|
|
|
|
i want to write ini file by WritePrivateProfileString function with out and delay. currently it take 2 to 3 seconds beacuse this function is work on cache file of ini file.
if system is being restart that time then we are unable to retrive information .
please suggest me how can i update ini file
|
|
|
|
|
Try WritePrivateProfileString(NULL, NULL, NULL, L"inifile.ini")
|
|
|
|
|
ok, this makes absolutley no sense as to why this is happening...
Here is the scenerio:
I have an INI file that gets uploaded into some product durring the test.
I have to modify the INI file before upload, so I do so using WritePrivateProfileString(x,x,x,x). Return value is good, no errors.
Read the settings I just changed in the INI file via the GetPrivateProfileString(x,x,x,x), values returned match what I changed them to,
ok, stop there.. (via breakpoint or messagebox)
Now, go into windows explorer and open the INI file and none of the data in the INI file has changed per the write command.
Now, exit the program, or stop it if in the enviornment. Now go and read the INI data from the INI file in windows explorer.. The data is now changed.
Or you can simplely write some data to a bogus file and it will force the INI file to get updated...
OK, now the reason this is such a problem is that after I modify the INI file I have to start the upload process, but I can't because the upload procss graps the file from windows, except the file hasn't been updated yet to the values I wrote using the writeprivateprofilestring command.
This makes no sense to me. Why is windows waiting to update the actual file? Is the a command I need to send to force windows to release the cach so that the file gets updated?
Hopefully someone can explaing what is going on here... Any information will help.. I hope I am so confused by this....
|
|
|
|
|
hello, i would like to write a small service that checks programs that write to registry.
does anyone have hints on this subjects?
i just wanna detect it.
detectif an aplication write/read fro the registry.
and if needed prevent from writing to the registry.
how to achieve this.
Bad = knowing 2 much
|
|
|
|
|
|
My guess would be to try to inject a dll into every process and hook the registry access methods. But as said, just a guess. Google for "injecting a DLL" and "hooking api calls" if you don't understand what i mean...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
yes, that's what i wanna do, hook a dll into 'windows' or explorer.exe.
just like sopme virusses, accept i wanna prevent them.
Bad = knowing 2 much
|
|
|
|
|
i could be completely wrong here but as far as my knowledge goes hooking into explorer won't affect any other processes trying to access the registry...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
wel, i don't know at all , but i wanna write sometol, to inform my customers that there is something wrong.
i probably need to hook in the kernel or so.
i read some of the links from msdn and codeproject, but stil nothing what i need, but good info.
: )
Bad = knowing 2 much
|
|
|
|
|
hmmmm, this is 'API hooking revealed[^]' instresting material.
it provide something i need.
hook all proceses.
atleast the test app's log told me exactly what programm i have open.
: )
Bad = knowing 2 much
|
|
|
|
|
Don't know which method of DLL injection you will choose but i guess since you want to monitor every process's attempts to access the registry you will choose the 1st method (Registry) under the "Injecting techniques" on the page you linked to in your post. Just a warning here, not everyone has the rights to read/write any parts of the registry, so don't get bad surprises e.g. when your proggie works great under Windows xp but fails on Vista (like i had this experience sadly ) or it works ok under the admin account but not under a normal user account. Anyways, i did some work with api hooking myself, so if you get stuck somewhere, ask away and if i can, i help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
wel the program is for my customers.
the computers i sell and install, debug & fix for my clients in my friends lilte store.
so i have 'admin' acces from first moment on.
yes, i wanna intercept any program a user executes and attempts to write to the registry.
but much investigation has to be done.
because some proceses execute as 'system' and not as user.
but in the first place, i only want to protect certains spots in the registry, you know the dangerous spots, run, runonce, etc, etc.
the 'hook' is targetted @ people that have no clue and just chat, navigate a litle.
Bad = knowing 2 much
|
|
|
|
|
Hi Guys,
I'm building a simple TCP/IP client/server application and can't find any examples that I could run in Visual Studio IDE. Everything seems to be MFC and it's not compiling under Visual Studio 2010 Express C++ for some reason. I'm not very skilled in the C++ area so please be patient with me. Something that compiles and runs out of the box please.
Regards,
Stevo
zilo
|
|
|
|
|