|
In C++, the only difference between structs and classes is that structs default to public access while classes default to private. Everything you can do in a class, you can do in a struct.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Vaclav_Sal wrote: pTest->test1 = 0;
Any pointer in your code should be initialised to NULL. If you delete a pointer, set it back to NULL. Otherwise, you get these errors. You can still get errors, you need to remember to check if the value is NULL.
if(pTest)
{
pTest->test1 = 0;
}
is the easiest way to do that. Note this won't work unless any uninitialised value for pTest is guarenteed to be NULL ( by you )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
OK,
the elements initialization works fine and I have set the pointer to NULL
in the default constructor and it still gives me "Access violation".
struct DH_Tag
{
DH_Tag()
{
m_Alpha = 0; // joint angle
m_LinkLenght = 0; // link lenght
m_Distance = 0; // jpont disatance
m_Theta = 0; // twist angle
}
float m_Alpha; // joint angle
float m_LinkLenght; // link lenght
float m_Distance; // jpont disatance
float m_Theta; // twist angle
}m_DH_Data,*pm_DH_Data; // link Denavit-Hartenberg data
Are there any notes on the web about using struct like this?
Thanks guys, you are a big help.
|
|
|
|
|
Hey, I think I got it.
pm_DH_Data = new struct DH_Tag;
Can I put thes in constructor?
|
|
|
|
|
Vaclav_Sal wrote: the elements initialization works fine and I have set the pointer to NULL
in the default constructor and it still gives me "Access violation".
If a pointer is null, you can't use it, you need to use the code I gave you to deal with this. So, use new if you want to use it. You can also lazy initialize ( call new when you need it and not before ).
Don't forget to call delete in your destructor
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Is there any simple way to take graphics.... drawn in either GDI+, DirectX, OpenGL, etc...and hook that executable process to a running or existing application or process....and if so can I use the SetWindowsHookEx to do so....?
Or more clearly, what are all the functions that I definitely need to use to accomplish this...?
Any help will be greatly appreciated!!
Thanks...
|
|
|
|
|
I'm sorry but I dont understand what you said
|
|
|
|
|
I'm trying to use hooks to hook a program written in C#, using GDI+ specifically to draw, to another existing/already running application/process. Do I need to use SetWindowsHookEx() or is there another way to hook?
Also, how do I go about the whole process of "hooking a process to another process"?
I hope this explains it a little better.
Thanks...
|
|
|
|
|
hi
i wanna open a MSWORD DOC such as double click on it but by my application call and pdf too.
WinExec(file path) is only for .EXE files and can not be used for .DOC or .PDF !
can u help me ?
|
|
|
|
|
ShellExecute will do this for you
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
tell more about ShellExecute plz
|
|
|
|
|
See here or here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
tanx a lot
|
|
|
|
|
I want to know how to set the first parameter?
a beginner
|
|
|
|
|
|
|
I have a bitmap image representing a button. I would like to use this same bitmap to represent different states of the button, in particular the default, mouseover and clicked states. Default is the bitmap as it is, but for the other two states I need to make the bitmap slightly lighter and darker. I am doing this by looping through the pixels and manipulating the RGB values.
To make it darker I use this simple formula
crPixel = RGB(
GetRValue(crPixel) * 0.8,
GetGValue(crPixel) * 0.8,
GetBValue(crPixel) * 0.8 );
Multiplying by 0.8 gives the desired effect. But for a lighter bitmap, I try multiplying by 1.2 which doesn't work. The bitmap appears green rather than lighter. Does anybody know the correct formula for adding white to a pixel?
|
|
|
|
|
The issue is that the human eye percieves different colors differently, if you google for a greyscale filter ( or read my C# image processing articles ), you'll get the ratios you need.
I'm not sure if you're using a DIBSECTION, if you aren't, you should.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sorry, I tend to stay clear of the C# articles. I already had the grayscale filter in place for the disabled button style. As for the DIB's, not yet. Most of the code is in place for it, as soon as it's working, then I will add the tweaks.
|
|
|
|
|
waldermort wrote: Sorry, I tend to stay clear of the C# articles.
*grin* Yeah, if you touch that stuff, the stains are murder to get out.
waldermort wrote: As for the DIB's, not yet. Most of the code is in place for it, as soon as it's working, then I will add the tweaks.
You'll use DIBs ? A DIBSection is a magical DIB that can still be selected into a DC and drawn that way.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
waldermort wrote: But for a lighter bitmap, I try multiplying by 1.2 which doesn't work. The bitmap appears green rather than lighter.
Are you making sure the RGB values don't go over 255?
Mark
|
|
|
|
|
That was probably the problem. I changed the formula so that it alphablends a white pixel, works fine now
crPixel = RGB(
GetRValue(crPixel) * dBlend + (1-dBlend) * 0xff,
GetGValue(crPixel) * dBlend + (1-dBlend) * 0xff,
GetBValue(crPixel) * dBlend + (1-dBlend) * 0xff );
|
|
|
|
|
convert the RGB to HLS ( or the other one ) and just play with the lightness value.
|
|
|
|
|
It is relatively easy to accomplish this if you calculate a HSL (Hue, Saturation and Luminosity) value based on the RGB value. Then modify the L-value, and convert back to RGB. There are tonnes of algorithms on the web for doing this. The only drawback is that it is quite slow, since all the algorithms I've seen so far, use floating point numbers for HSL values.
In any case, it's not equivalent to applying a linear factor on each RGB color component. Been there, done that. It works well on some color nuances, but will look like crap most of the time.
--
For External Use Only
|
|
|
|
|
Thanks for the info, but in the case of my app it's a little of an overkill. I just need a very simple way to extend on a default image in the case a user did not specify one.
|
|
|
|