|
Am not exactly sure i understand what you mean there, but i did run into the following "problem" with the up-down buttons: when you get the notification message from the control, the control's value did not get changed yet, only after the message. (So, if the control's value is 2, and the user presses the up button to increase it, you get a notification, if you ask the control about its current value in the message handler, you get 2, and then after the message handler has returned it will change to 3.). However, the notification message also has some parameters telling you weather the user increased or decreased the numeric value and you can use this to figure out the current number, look up the documentation for it and you will know what do to. Good luck and happy xmass.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi,
I have a class with constant member variable. As constant member variables MUST be initialized in the constructor initializer list, how do I write an assignment operator for such a class. E.g.
class MyClass
{
public:
MyClass() : m_ConstantMember(0) - (1)
{}
MyClass(int intvar) : m_ConstantMember(intvar) - (2)
{}
MyClass(MyClass const& rhs) - (3)
: m_ConstantMember(rhs.m_ConstantMember)
{}
MyClass& operator = (MyClass const& rhs) -- (4)
{
if(this != &rhs)
{
m_ConstantMember = rhs.m_ConstantMember; -------- (4a)
//memcpy((void*)&m_ConstantMember,
(void*)(int*)&rhs.m_ConstantMember,
sizeof(m_ConstantMember)) ------------ (4b)
}
return *this;
}
private:
int const m_ConstantMember;
};
The above class has one constant member variable of type int. This variable MUST be initialized in the constructor initializer list. This is achieved in the above class by
1. No argument constructor
2. One argument constructor
3. Copy Constructor
For the assignment operator, if I write a statment as in 4a, the compiler complains. However if I write the statement as in 4b, the compiler is happy and I get the desired result.
So my query is whether the statement 4b is the correct way of writing an assignment operator for a class with constant member variable? If not can someone please tell me the correct way of writing the assignment operator.
Thanks and Regards.
|
|
|
|
|
Why are you trying to chqange the value of a const? Constants are constants because their value is constant, it does not change during their lifetime. The compiler complains about it because basicly you are telling it to: "make a constant whose value never changes once it is set, and now chane it.". if you want to change the value then don't make it const.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Ask yourself these questions:
1) Why does the const member *have* to be const? If you made it non-const, life would be a lot simpler for you. What's the rationale for const?
2) Why do you need an assignment operator? An assignment operator makes little or no sense when part of the class is const.
My gut feel is that when you're trying to work around things like this, something in the design is out of kilter and needs fixing.
|
|
|
|
|
Hello Guys,
Thanks a lot for your response. As far as the class goes it's not a design issue. I just wanted to find out how to write a proper an assignment operator of for a class with contant member. So it was just out of curosity that I wrote a sample class.
Regards
|
|
|
|
|
Hi all,
in printing i want to print a image i m using this code.its works but the imgae displayed very-very small.or its only works for image that is add in resource.
<br />
CBitmap bmp;<br />
if (bmp.LoadBitmap(IDB_BITMAP1)!=0)<br />
{<br />
BITMAP bmpInfo;<br />
CRect rect;<br />
bmp.GetBitmap(&bmpInfo);<br />
<br />
CDC dcMemory;<br />
dcMemory.CreateCompatibleDC(pDC);<br />
<br />
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);<br />
<br />
int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;<br />
int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;<br />
<br />
pDC->BitBlt(rect.left, rect.top, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,0, 0, SRCCOPY);<br />
}<br />
<br />
i want to use any image that is browse by any location.please tell me what can i do for this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: its works but the imgae displayed very-very small.
The problem is that, usually the resolution of the printer DC's are very high, it depends on the dpi of the printer and paper size you choose( . I think you can get the resolution of printer dc using the DocumentProperties() function. Then instead of using the BitBlt , use StretchBlt and strech the image to the required size.
|
|
|
|
|
Can u please explain with example.
and please tell me what can i do for Browsed image.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: and please tell me what can i do for Browsed image.
You mean the image you directly load from the file? There is no difference in printing those images and images in the resource. Only thing is, you have to use the LoadImage () function to load images from the file.
|
|
|
|
|
Change BitlBlt to StretchBlt and see Printing a Document[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Just an addition to what Hamid suggested there, when i was working on -let's call it- printing systems i had the pleasure to meet printer drivers which did not support StretchBlt at all, only BitBlt and i had to substitute StretchBlt with creating a memory DC and bitmap the size of the needed target, StretchBlt-ing the original image onto this memory area and then BitBlt this to the printerdc.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
You could use like below
CString sFileLocation = "C:\\Test\\SomeFile.bmb" \\Get it by browsing.
HBITMAP hBmp = (HBITMAP)LoadImage(NULL, sFileLocation, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
|
|
|
|
Guys! where are the experts when you need them?!
i'm not an expert on this stuff! but i have to work on the audio-video calls in the chat project i have!!
do anyone have ideas about video and audio streaming on a network??
any ideas about using DirectShow??
|
|
|
|
|
Mind Machine wrote: Guys! where are the experts when you need them?!
Ho....I stepped out for a tea.
Mind Machine wrote: do anyone have ideas about video and audio streaming on a network??
Many of us had. And they have put those ideas as articles in code project. Do you mind having a search among those articles?
|
|
|
|
|
I think, RTP is the protocol you are looking for.
You may need some codecs also to minimize the bandwidth usage.
Try exploring the SIP (Session Initiation Protocol) standard which will give you an idea of calls over the network with media streaming. You can also go through codecs G.723 and G.711A-Law and G.711Mu-Law where windows have built in support and can be accessed via ACM (Audio compression manager).
Good luck
cheers
Varghese Paul
|
|
|
|
|
Mind Machine wrote: Guys! where are the experts when you need them?!
[code]
Dont worry,they see you and they are thinking!
[/code]
Did you see audio-video[^]?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi,
Programmatically, Instead of standard printer, I want to print report to a file ("Print To File" option in Print Dialog). I use IWebBrowser to navigate the report in my code.
1. I have a report file, XML and XSL based report, viewable in IE.
2. In my program, I use IWebBrowser to navigate report in background, before sending it to standard printer.
3. Now I want to print this report to a file programmaticaly, ("Print To File").
Please refer sample code below,
void PrintReport(CString strReportName, OLECMDEXECOPT enumPrompt)
{
::OleInitialize(NULL);
void PrintReport(CString strReportName, OLECMDEXECOPT enumPrompt)
{
::OleInitialize(NULL);
try
{
SHDocVw::IWebBrowserAppPtr ptrWebBrowserApp(__uuidof(SHDocVw::InternetExplorer));
SHDocVw::IWebBrowser2Ptr ptrWebBrowser = ptrWebBrowserApp;
_variant_t vtDummy;
HRESULT hr = E_FAIL;
BSTR bUrl = strReportName.AllocSysString();
hr = ptrWebBrowser->Navigate(bUrl, &vtDummy, &vtDummy, &vtDummy, &vtDummy);
VARIANT_BOOL bBool = ptrWebBrowser->Busy;
while(ptrWebBrowser->Busy == VARIANT_TRUE)
{
::Sleep(1000);
}
IOleCommandTargetPtr ptrOleCmdTarget = ptrWebBrowser->Document;
<big>
hr = ptrOleCmdTarget->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER , NULL,NULL);
}
catch(_com_error& e)
{
_ftprintf(stderr,
_T("Error: 0x%08X (%s); Source: %ls; Desc: %ls"),
e.Error(), e.ErrorMessage(),
LPCWSTR(e.Source()), LPCWSTR(e.Description())
);
}
::OleUninitialize();
}
Any help would be highly appreciable.
Regards,
Paresh.
|
|
|
|
|
Hello, all I am working with Dev-Cpp, and I have the folowing code to read a file:
#include <fstream.h>
...
char buffer[100];
ifstream myFile ("data.bin", ios::in | ios::binary);
myFile.read (buffer, 100);
if (!myFile) {
}
...
if (!myFile.read (buffer, 100)) {
}</fstream.h>
now, I have the base64 class from here: www.adp-gmbh.ch/cpp/common/base64.html[^]
How I can convert the buffer into base64?
|
|
|
|
|
From looking at the code you linked to, it looks like you would do the following:
std::string EncodedString;
if ( myFile.read ( buffer, 100 ) )
{
EncodedString = base64_encode( buffer, 100 );
}
|
|
|
|
|
WOW!!!
How near i was!!!
Thank you a lot!!!!
Now, a little problem, how I can get the size of the file, to get all the base64?
modified on Wednesday, December 24, 2008 12:44 PM
|
|
|
|
|
I'm not familiar with the class you're using to read the file, so I'm afraid I can't help you there. But have a good holiday!
|
|
|
|
|
Well, base 64 means that there are 64 characters in the character set. It takes 6 bits to represent the characters 0-63, so multiply the number of bytes by 8, and divide by 6 to get the converted character count (probably need to add 63 to the byte count times 8 before dividing to catch any partial character at the end).
Dave.
|
|
|
|
|
Thanks for your help, but I was meaning the size of the file, to dinamically adjust the size of the char array and the second parameter of the read command.
Happy holidays for you too
EDIT: Solved I got the size with the stat() function, now it is working flawless.
Thank a lot, CodeProject is great!!
modified on Thursday, December 25, 2008 6:04 AM
|
|
|
|
|
Possibly reading a Good C/C++ tutorial: you've to pieces of code already done. Is it so difficult to glue them a bit?
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
[My articles]
|
|
|
|
|
Hi
Did you get my mail?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|