|
Hi~
Window API has a lot of const or macro
e.g S_OK, WM_PAINT, SW_NORMAL, etc.
Where can I find the value?
I cannot find them in MSDN
THanks
|
|
|
|
|
ting668 wrote:
Where can I find the value?
Just hover your mouse above them and you will see the value.
OR right-click and select go to definition.
<marquee> STUCK STUCK STUCK STUCK
Stuck to Programming through an unbreakable bond
My Articles | My Blog
|
|
|
|
|
I am creating a COM component in VC++ using MFC and automation. The automation process is via the CCmdTarget class and IDispatch. The component is a wrapper for accessing a proprietary binary file which holds information pertaining to a scanning system we use. Specifically each binary file will hold information relating to a particular form setup, such as how many sheets the form has the fields which we are capturing off the form and so on (the package is called IST). A portion of the object model for the file structure is as follows:
Application (only one)
----Records (contains all the fields)
--------Fields
----Documents
--------Sheets
------------Grids (maybe OMR or OCR region on the form, and will link back to one a field)
etc..
The structure is stored on disk in the above manner, and read into structs. The way I have gone about exposing the structs is via nested objects and collections of objects (CTypedPtrArray). So as an example I have exposed the records as IRecord and IRecords, IRecords is a collection of IRecord objects. The annoying aspect of this is that each IRecord object must hold a pointer to the record structure that has been read off disk. This pointer is setup during construction of the collections after it has been read off disk, and will allow us to write back the information to disk if any changes are made.
This is all working fine (from what I can tell) however there appears to be a memory/access violation issue when the objects go into final release.
So I’m just wondering whether anyone has any advice with relation to automation, and how to appropriately dispose of objects.All the destructors are virtual in the component. Is that causing any problem? Could anyone please clarify that whether the destructors should be made virtual in COM? I am happy to send the project if required.
Thanks in advance.
|
|
|
|
|
you are missing some thing some where
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
You might be using smart pointers and somewhere calling release on some interface pointer. This might be the cause. Check that out
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
(My COM Blog - http://lovecom.blogspot.com)
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Sohail Bhai,
Happy Ramadan.
any knowledge about how to create Evallution dll,Runtime Dll or Developer DLL.
just need a little pointer towards that
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Is there any Windows Audio Api's which allows for specifying any varying sample rate, other than fixed defaults. (8000, 11025, 22050, 44100)?
Thanks
|
|
|
|
|
Should I do this:
#include <iostream>
using namespace std;
or should I do this:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
.
.
.
I find that making the namespace std global in implementation
file easier to work with, but some people suggest avoid doing
that. Should I? Do you make namespace std global?
Thanks,
Alex
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
The second option is neater, and better style. In the real world, it's doubtful that you'll notice the difference. I always do the second, to be a nerd.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I rarely use either. The whole point of namespaces is to be able to separate groups of things to avoid name clashes. The using directive basically gets rid of the namespaces and puts everything in the global namespace, making the use of the namespace pointless, especially the first form. If I do use the using directive, I use the second form. It's a lot cleaner and helps to prevent clutter of the global namespace.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Okay, so if I use using namespace std;, does that mean the program will compile everything named under namespace std? Many people recommend not to make the namespace std global, but some say it doesn't matter. But I usually do the second way, typing explicitly using::string, using::cout......until I read the newly released book from Andrei Alexandrescu (highly repected person in the field), the book named C++ coding standard. (ISBN: 0-321-11358-6)
Here is a quote from the book:
But here's the common trap: Many people think that using declarations issued at namespace level (for example, using N::Widge) are safe. They are not. They are at least as dangerous, and in a subtler and more insidious way.
After reading this, I was thinking, am I doing the right way? So I thought I would ask people here how they are doing it.
<br />
#include <iostream><br />
using namespace std;<br />
<br />
int main()<br />
{<br />
return 0;<br />
}<br />
or should I do this:
<br />
#include <iostream><br />
using::cout;<br />
using::cin;<br />
using::endl;<br />
<br />
int main()<br />
{<br />
<br />
return 0;<br />
}<br />
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
Alex Ngai wrote:
But here's the common trap: Many people think that using declarations issued at namespace level (for example, using N::Widge) are safe. They are not. They are at least as dangerous, and in a subtler and more insidious way.
Which is exactly why I rarely use them either. Promoting any namespace member to the global namespace (which is what the using directive actually does) has the rather dangerous ability to shadow a member already in the global namespace with the same name, much like an overloaded function, but a lot more subtle. These errors can be very difficult to debug.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks for your reply.
But many feature in stardard C++ are in namespace std. Even the simple input & output, string are in namespace std.
So, should I stick with using::string style? Is it better or it doesn't matter, like what the author said?
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
My preference is to use individual using std::string; type statements instead of bringing the whole std namespace in with using std;
But of course there is no reason why you have to use using ...; at all. You can just use the full names at the appropriate points. eg
std::cout << "This is a test" << std::endl;
Instead of
using std::cout;<br />
using std::endl;<br />
<br />
cout << "This is a test" << endl;
Mike
|
|
|
|
|
Mike Beckerleg wrote:
You can just use the full names at the appropriate points.
Indeed, I prefer to use the explicit full names. It is then obvious which function you intend to call.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote:
Indeed, I prefer to use the explicit full names. It is then obvious which function you intend to call.
Exactly
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is there a way to UNATTENDEDLY lock and unlock a workstation ? Could this be done by MacroScheduler? If I use a C++ programming, what kind of API will do ? I tried keybd_event(), but not work.
lParam = MakelParamValue(0, VK_MENU, 0, 1, 0, 0); // alt key down
keybd_event(VK_MENU, 0, 0, lParam);
lParam = MakelParamValue(0, VK_CONTROL, 0, 1, 0, 0); // Ctrl key down
keybd_event(VK_CONTROL, 0, 0, lParam);
lParam = MakelParamValue(0, VK_DELETE, 0, 1, 0, 0); // Del key down
keybd_event(VK_DELETE, 0, 0, lParam);
//
lParam = MakelParamValue(0, VK_DELETE, 0, 1, 1, 1); // Del key up
keybd_event(VK_DELETE, 0, KEYEVENTF_KEYUP, lParam);
lParam = MakelParamValue(0, VK_CONTROL, 0, 1, 1, 1); // Ctrl key up
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, lParam);
lParam = MakelParamValue(0, VK_MENU, 0, 0, 1, 1);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, lParam); // alt key up
My email: xueshunnai@hotmail.com or xueshunnai@aol.com
Thanks!
xsn
|
|
|
|
|
|
Everybody, Hi!
How to create property window, Visual Studio.NET like?
Help, Please!
|
|
|
|
|
Hi,
I want to display load and display and image which present in the directory in VC++. I will be using menus, toolbars... Using SDI, we can get toolbars inbuilt and not much of code to be written, but I do not know how to display an Image, as there are no controls to place. Using Dialog based, there is no menus and toolbars.
I wanted to know, which is the better one to do an image processing project and also how to display and image.
Please do help.
Thanks
|
|
|
|
|
you can look for CxImage Libaray Inthis Site,very good S/W for Image Processing
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
I'm having trouble with that function. I have a block representing an RGB image with 8 bits per color value. I wanted to use the function SetDIBitsToDevice to output this image to screen. The problem is that the function returns 0 (error because 0 lines set) and GetLastError() function also returns 0. So I don't know what the problem is. Even if the image I have is screwed up I thought it should output some kind of weird thing to the screen or at least crash.
Here's my code inside OnPaint() function of ChildView:
<br />
CPaintDC dc(this);<br />
BITMAPINFO m_bitmapInfo; <br />
m_bitmapInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );<br />
m_bitmapInfo.bmiHeader.biWidth = m_nOutputWidth;<br />
m_bitmapInfo.bmiHeader.biHeight = -m_nOutputHeight;
m_bitmapInfo.bmiHeader.biPlanes = 1;<br />
m_bitmapInfo.bmiHeader.biBitCount = 32;<br />
m_bitmapInfo.bmiHeader.biCompression = BI_RGB;<br />
m_bitmapInfo.bmiHeader.biSizeImage = ::abs( m_nOutputWidth*m_nOutputHeight ) * 3;<br />
m_bitmapInfo.bmiHeader.biXPelsPerMeter = 100;<br />
m_bitmapInfo.bmiHeader.biYPelsPerMeter = 100;<br />
m_bitmapInfo.bmiHeader.biClrUsed = 0;<br />
m_bitmapInfo.bmiHeader.biClrImportant = 0;<br />
<br />
int val = ::SetDIBitsToDevice(<br />
dc.GetSafeHdc(),<br />
0, <br />
0,<br />
m_bitmapInfo.bmiHeader.biWidth, <br />
m_nOutputHeight,<br />
0, <br />
0,<br />
0, <br />
m_nOutputHeight,<br />
m_pImageData,
&m_bitmapInfo, <br />
DIB_RGB_COLORS );<br />
DWORD err = ::GetLastError();<br />
Thanks for the help.
|
|
|
|
|
I set m_bitmapInfo.bmiHeader.biBitCount = 32;
and the image is 8 bits per pixel. I wish it would have crashed instead of doing nothing and making it hard to debug.
|
|
|
|
|
Blast that was I was going to mension!
I found that the functions that deal with DIBs image data in this fashion tend to fail if the information is not exactly correct WITH OUT generating an error that explanes why it failed.
The GetDIBits() will also fail in the same way WITH OUT an explanation.
I do not know what you are using this for but I would just make the DIB information a member which is updated when that data is changed. That way you will not have to do all that initiation in the OnPaint() function. Of course for a simple application the drawing speed increase would not even be noticable.
INTP
|
|
|
|
|
Hi,
i try to put my small icon in systemtray, for this, i have one icon, IDI_ICON1 with two draws (one with 32x32 and the other with 16x16) but when I use Shell_NotifyIcon(NIM_ADD, IDI_ICON1) the program adapts the 32x32 icon why doesn't use the small icon directly? What I have to do?
Thanks
|
|
|
|
|