|
Better you use EnumWindows()[^] to enumerate all the windows and check the window handle you receive in the call back function with the handle retrieved with GetWindow()[^] function (by passing desktop window handle as first parameter and GW_CHILD as second parameter). Even you can compare the same handle with the handle returned by GetForegroundWindow()[^], but there could be chance that the foreground window isn't the topmost in the z-order.
|
|
|
|
|
I am currently working on a program which uses a GUI (written in C++ with MFC) to gather data from a user. When the user hits go, the program then analyzes the data and returns the results back to the user. The elapsed time between the time the user hits go and the results are returned is approximately 1 minute. In certain cases, it could be as high as 10 minutes. During that time, the program ignores any mouse clicks and when I bring up the Window’s task manager, the status of the program is that it is not responding. However, the calculations are complete, the program response as expected. However, for an end user, I do not believe that the program just hanging is acceptable. For example, if minimized and then restored it needs to be able to repaint the screen.
What should I do to remedy the situation? I am thinking that if I did the calculation in a separate thread that it would solve this problem. What do you think of this idea? Maybe somebody knows a better way to handle this situation.
Thanks
Bob
|
|
|
|
|
Hi! Since the data processing procedure is running in UI thread, so no message processing operation will be performed, and that is the reason of blocking of the user interface.
A simple solution is when user click the "Start" button, set the state of the UI elements (e.g. enable or disable) correctly to avoid invalid user operation and run the data operation from another thread. You can place a process bar on the form to indicat that the application is in "Busy" state while data processing is running.
|
|
|
|
|
Yes, doing the analysis in a separate thread is the way to go. See this[^] link.
/ravi
|
|
|
|
|
try "sleep(0)" this will make windows execute its message queue
here's msdn explanation:
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution.
A value of INFINITE indicates that the suspension should not time out.
|
|
|
|
|
dehseth wrote: try "sleep(0)" this will make windows execute its message queue
Actually it won't. You still need to manually flush the message queue by calling PeekMessage() in order to convey the impression of multi-threading.
/ravi
|
|
|
|
|
I am using visual c++ and using the numericupdown button to control the change of picturebox's image, I have set the numericupdown from 0 to 90 and set the program like the following, but then I discover that when I press up down button to change the value in numericupdown, 1 represent 0, 2 represent 1...the number is shifted(i use the textbox to check hte numericupdown->value)so,those image show in the picturebox are not in correct order.....How can I solve it??
private: System::Void numericUpDown1_ValueChanged(System::Object^ sender, System::EventArgs^ e) {
a = numericUpDown1->Text;
b=Int32::Parse(a);
switch (b)
{
case 0 : pictureBox1->Image = Image::FromFile("r1.jpg");
textBox1->Text=a;
break;
case 1 : pictureBox1->Image = Image::FromFile("r2.jpg");
textBox1->Text=a;
break;
default: pictureBox1->Image = Image::FromFile("r3.jpg");
textBox1->Text=a;
break;
}
|
|
|
|
|
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?
|
|
|
|