|
cuteee wrote: I see that this Array is getting emptied for some reason. could you please help me with this?
For some unexplained reason, I'm unable to get access to your computer. Can you please post a code snippet that exhibits the problem? How are you populating the CArray object? What happens right after that?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I have been using a simple routine to wait while connected hardware is performing a reset, ...
The routine is:
<br />
DWORD stop_time = GetTickCount() + iCount;<br />
while ((long)(GetTickCount() - stop_time) < 0L){<br />
MSG msg;<br />
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
}<br />
Someone has complained that the task manager in XP is showing that the CPU usage goes to 100% during this wait period. Do I need to add a sleep in there or something else to prevent this?
|
|
|
|
|
Yes. PeekMessage does not wait for a message to appear on the message queue before returning.
Deus caritas est
|
|
|
|
|
Instead doing a busy wait try something like this:
UINT_PTR tid = SetTimer(NULL, 1, 5000, NULL);<br />
MSG m;<br />
while (GetMessage(&m, NULL, 0, 0))<br />
{<br />
TranslateMessage(&m);<br />
DispatchMessage(&m);<br />
<br />
if ( m.message==WM_TIMER && m.wParam==1 )<br />
{<br />
break;<br />
}<br />
}<br />
KillTimer(NULL, tid);
Steve
|
|
|
|
|
|
How do I go about starting this? Any help will be greatly appreciated.
Using the existing point class below, add overloaded operator methods
to perform the following:
1. Binary addition
2. Binary substraction
3. Binary multiplication
4. Binary division - division by zero should result in a point with
>coordinates (0,0) returned.
The overloaded operator method functions should perform under the
>following conditions:
1. point operator point; i.e. p+p, p-p, p*p, p/p
2. point operator int; i.e. p+i, p-i, p*i, p/i
3. int operator point; i.e. i+p, i-p, i*p, i/p
Point Class
//Class Point
//File: Point.h
#ifndef _POINT_H_
#define _POINT_H_
using namespace std;
class point
{
private:
int _x;
int _y;
public:
point() //default constructor
}
_x=0;
_y=0;
}
point(int x, int y)
{
_x=x;
_y=y;
}
~point() //destructor
{}
void print();
void set(int,int);
};
#endif
>/*-------------------------------Point.cpp-------------------------*/
// Class Point Member Definitions
// File: Point.cpp
#include <iostream>
#include "point.h"
void point::print()
{
cout << "Point (" << _x << "," << _y << ")\n";
}
void point::set(int x, int y)
{
_x = x;
_y = y;
}
>/*---------------- TestPoint.cpp ------------------------*/
// Class Point Test Program
// File: TestPoint.cpp
#include <iostream>
#include "point.h"
using namespace std;
void main (void)
{
point p1;
point p2(5,6);
point p3;
int x;
int y;
cout << "Input p3 x coordinate: ";
cin >> x;
cout << "Input p3 y coordinate: ";
cin >> y;
p3.set(x,y);
p1.print();
p2.print();
p3.print();
|
|
|
|
|
homework ???
add these code in the class point...
class point
{
//old code.....
//
// my add constructor... int.
point(int single)
{
_x=single;
_y=single;
}
// overloaded operator methods ....
friend point operator +(const point& p1,const point& p2) {
return point(p1._x+p2._x , p1._y+p2._y);
}
friend point operator -(const point& p1,const point& p2) {
return point(p1._x-p2._x , p1._y-p2._y);
}
friend point operator *(const point& p1,const point& p2) {
return point(p1._x+p2._x , p1._y*p2._y);
}
friend point operator /(const point& p1,const point& p2) {
if (p2._x==0 || p2._y==0) return point(0 , 0);
else return point(p1._x/p2._x , p1._y/p2._y);
}
//~..
};
//then you can using like....
p3=p1+p2;
p3=p1-p2;
p3=p1*p2;
p3=p1+1;
p3=p1/100;
p3=p1/0;
..........
......
|
|
|
|
|
Hi
When I try to use these (FD_ACCEPT and FD_CONNECT) events In following function call:
WSAEventSelect(sock, event, FD_ACCEPT|FD_CONNECT|FD_WRITE ...),
the FD_CONNECT event can be gotten, but FD_ACCEPT and FD_WRITE can not be gotten.
What is the reason for this?
Thanks
|
|
|
|
|
When are you expecting the other two socket events to trigger your event handle? For example, the FD_WRITE event is not "fired" when you write on the socket, but if you fail to do a non-blocking send on a socket AND then when the socket gets to a state where the write would be able to complete successfully.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hello all,
This should be easy but for some reason I am having troubles... I am trying to create a simple 3 view split in a SDI... I want the split to look like an upside down T, so a Left Top Pane, Right Top Pane, and a Bottom Pane (The bottom Pane needs to go from one side of the frame to the other). Here is what I am trying...
if(!m_wndSplitter.CreateStatic(this, 2, 2))<br />
return FALSE;<br />
<br />
if(!m_BottomSplitter.CreateStatic(&m_wndSplitter, 1, 1, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(1,1)))<br />
return FALSE;<br />
<br />
if( !m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(175, 175), pContext) ||<br />
!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), CSize(100, 100), pContext))<br />
{<br />
m_wndSplitter.DestroyWindow();<br />
return FALSE;<br />
}<br />
<br />
if(!m_BottomSplitter.CreateView(0, 0, RUNTIME_CLASS(CBottomView), CSize(100, 100), pContext))<br />
{<br />
m_BottomSplitter.DestroyWindow();<br />
return FALSE;<br />
}
Any ideas?
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Try this:
Assuming that you want a view layout like this:
The trick is basically creating your splitter window within the other in order to get the right layout.
The first splitter divides your window into two rows. Then using a second splitter, subdivide the upper row into two columns.. and viola
<br />
if(!m_wndSplitter.CreateStatic(this, 2, 1))<br />
return FALSE;<br />
<br />
if(!m_wndSplitterB.CreateStatic(&m_wndSplitter, 1, 2, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0,0)))<br />
return FALSE;<br />
<br />
if (!m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CBottomView),CSize(100, 100), pContext))<br />
{ <br />
TRACE0("Failed to create LeftView\n");<br />
return FALSE;<br />
}<br />
<br />
if (!m_wndSplitterB.CreateView(0, 0, RUNTIME_CLASS(CLeftView),CSize(100, 100), pContext))<br />
{ <br />
TRACE0("Failed to create LeftView\n");<br />
return FALSE;<br />
}<br />
<br />
if (!m_wndSplitterB.CreateView(0, 1, RUNTIME_CLASS(CRightView),CSize(100, 100), pContext))<br />
{ <br />
TRACE0("Failed to create LeftView\n");<br />
return FALSE;<br />
}
I Dream of Absolute Zero
|
|
|
|
|
RobJones wrote: Any ideas?
Yes. See the VIEWEX example on MSDN.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I have a class that will recieve TCP data frames through a socket and store them in a buffer. The buffer space is allocated by my client application and a pointer is sent to my class. I plan to protect read/write operations with a mutex or some ohter form of shared memory protection.
Can I have my class post a message or signal an event to alert the client app that data has been received and stored? Or is there a more "elegant" way of accomplishing this?
Thanks.
|
|
|
|
|
I usually provde an interface that allows the clinet to specify an event handle to wait on, or else they specify a message ID and window where they want a message posted.
Some developers might be in a message queue looking for activity, and others might want to have a worker thread waiting (no message queue at all) so you give them both choices.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
I have a small dialog box that accepts an inputfield and then shows some results on pressing the "Show" button. The box also has an OK button to close it. I would like that, when the user presses the Enter key, this activates the "Show"" button rather than the OK button. However, I cannot get the Show button to become the default dialog's button. Enter always results in immediately quitting the dialog. Must be something quite trivial, but haven't yet found it.
Any ideas anyone?
Thank in advance,
William
|
|
|
|
|
Uncheck the ok button's default attribute and check the default button attrtibute on the Show button via the dialog editor.
If you are doing this via code, you need to clear and set the BS_DEFPUSHBUTTON style.
onwards and upwards...
|
|
|
|
|
Thanks a lot; this works just fine.
William
|
|
|
|
|
|
hi..
i need a sample program for
"opening and closing ACS Stream"
will u please provide me with the above..
yamuna
|
|
|
|
|
I am working on a scanning project. The scanners I am working with do not support TWAIN job control. We are wanting to fake job control by using solid black pages as our job control pages. The TWAIN software I am using gives me a DIB per page that is scanned. I want to inspect the DIB during scanning and start a new image when I find a solid black image. I have looked around but can't find anything that does this. I was wondering if anybody had a suggestion. Please let me know.
|
|
|
|
|
You can loop through the byte array RGBQUAD values in the pixel data and compute the percentage of black. If the RGB value is, let's say, less than RGB(5,5,5) then consider it black. Otherwise, consider it non-black.
onwards and upwards...
|
|
|
|
|
That's what I like - a simple, brute-force approach! Not elegant but entirely functional. And speed is not an issue, since it will be way faster than the scanning process.
|
|
|
|
|
I want to change my Win32 console Application exe Symbol by a given .bmp image.Pls guide me how to do it.Actually i am stuck up how to replcce it with my .bmp image
Pls help me.Thanx in advance
never say die
|
|
|
|
|
|
Actually I want to change the icon (symbol) of Win 32 console .exe by any .bmp or .ico.So that my symbol appears rather than the default symbol of .exe is visible
Pls help me
never say die
-- modified at 9:43 Wednesday 15th February, 2006
|
|
|
|
|