|
What do I need to look at the http://www.freebsd.org/?
Thank You
Regards,
ntuyen01
|
|
|
|
|
|
I'm writing a program which needs to get the mouse capture in order to be able to select a part of the screen. I've tried this using GetCapture, but that doesn't work, because at the moment I start dragging at a point that is not in the my app's window, the capture is lost and the window at that point is activated.
Is there some way to prevent this loss of capture AND focus?
|
|
|
|
|
I'm trying to set up a function which sorts the 10 elements of my array utilizing pointers. It's just a learning exercise for my C++ class. Can anyone explain why the following code only makes 1 iteration and how I can get it to keep moving?
void sort(int iArr[], int size)
{
int *iPtr = iArr;
for (int i = size-1;i>0;--i)
for (int j=0; j<i; ++j)
="" if="" (*iptr=""> *iPtr+1);
{
int temp = *(iPtr);
*(iPtr) = *(iPtr+1);
*(iPtr + 1) = temp;
}
}
|
|
|
|
|
Anonymous wrote:
for (int j=0; j if (*iPtr > *iPtr+1);
do you mean:
for (int j=0; j if (*iPtr > *(iPtr+1));
?
also, don't you need to move the pointer somewhere? looks like iPtr is always pointing at the first element of the array.
Software | Cleek
|
|
|
|
|
It seems as though no matter where I put the code to increment iPtr, I still only get one iteration. Seems like this should be so simple, but no matter what I do I can't get it to work. The assignment was to take a previous assignment and write it so that the print & sort funtions are handled with pointers instead of arrays. Can you give me advice as to where in the code that I wrote I would insert the increment? Yes, I'm a newbee. I took structural C 4 years ago and I'm afraid I've lost a lot in 4 years.
|
|
|
|
|
it's kindof hard to tell what's going on with your code, since the board reformatted it a bit.
try reposting it inside <pre>...</pre> tags, and put spaces after any < signs (like in your for loops and in the if(...). that should keep the board from doing too much damage.
Software | Cleek
|
|
|
|
|
Thanks for your help. At this point my class is in 3 hours, so I'm going to just get the teacher to help me out. I think part of the problem is that I'm basing this portion of code on the original program which didn't utilize pointers, and I'm getting very confused. Your time is much appreciated. This is a great board. Take Care,
Dawn
|
|
|
|
|
Anonymous wrote:
Can anyone explain why the following code only makes 1 iteration...
What is the value of size ? If it is 2, then the outer loop would only execute one time.
There are other reasons why this routine will not produce the desired result but we'll get to those once the loop issue is resolved.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
When I wrote this little program below, I didn't even define the value of size, and it executes with the desired results. I get one print out of the array, and the second time the print function executes the list is sorted. When I try to employ this same logic using pointers, the sort loop only makes one iteration:
#include <iostream>
using namespace std;
void Print (int [], int);
void Sort (int [], int);
void main()
{
const int max =10;
int list [max] = {7, 4, 9, 1, 8,
3, 6, 5, 0, 2};
Print (list,max);
Sort (list, max);
Print (list, max);
}
void Print (int array [], int size)
{
for (int i=0; i<size; i++)
cout="" <<="" array="" [i]="" "="" ";
cout="" endl;
}
void="" sort="" (int="" [],="" int="" size)
{
for="" i="size-1;i">0;--i)
for (int j=0; j<i; ++j)
if="" (array="" [j]=""> array [j+1])
{
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
This programs works beautifully.
|
|
|
|
|
Dawners wrote:
I didn't even define the value of size...
Actually you did. It had a value of 10.
When switching from array[] to pointers, keep in mind that array[j] is equivalent to *(array + j) .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
How are you coming along with this?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
LOL
If you look really close then you would see why the loop is making all the iterations you want, but your code gets only executed once... If you used the debugger, you would've solved the problem in no-time.
I don't understand why the other people on this board have been so sloppy not to see the ; behind the 2nd for loop!!!!! Remove that and you'll have no problem...
Next time, use the debugger first.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Good eye;
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Bob Stanneveld wrote:
I don't understand why the other people on this board have been so sloppy not to see the ; behind the 2nd for loop!!!!!
This is a forum display error!!! If you look closely it is a combination of 2 lines the lines should show
for (int j=0; j<i; ++j)<br />
if (*iPtr > *iPtr+1);
You need to look at the HTML source to find this out!
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 Williams (Little Britain)
|
|
|
|
|
Oops, this is the point where I should hit myself and be ashamed of accusing people of not seeing an error that I out of a few did not see...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
void sort(int iArr[], int size)
{
for (int i = size-1;i>0;--i)
{
int *iPtr = iArr;
for (int j=0; j < (size - 1) ; j++)
{
if ( *iPtr > *(iPtr+1) )
{
int temp = *iPtr;
*(iPtr) = *(iPtr+1);
*(iPtr + 1) = temp;
}
iPtr++;
}
}
You have forgot to increment the pointer in the inner for loop and reset the same in outer for loop
Sandeep Naik
|
|
|
|
|
use the following lines of code to sort your array. basically your second for loop has syntex error and you have used wrong swaping logic.
i have rectified all those errors and hope its working fine now
here u r
void sort(int iArr[], int size)
{
int *iPtr = iArr;
for (int i = size-1;i>=0;i--)
{
for (int j=i-1; j>=0;j--)
{
if ( *(iPtr+i) < *(iPtr+j) )
{
int temp = *(iPtr+i);
*(iPtr+i) = *(iPtr+j);
*(iPtr + j) = temp;
}
}
}
}
from
Azam
|
|
|
|
|
I'm trying to create a bitmap on the fly. Once the bitmap is created, it will be passed to a toolbar class (CodeJock's CXToolBar) to apply to a button. The following code snippet is what I have so far. It compiles but I haven't run it yet because I have some questions:
1) How close am I?
2) What am I missing?
3) Do I have to keep the bitmap around after I've passed it into the toolbar?
CString sText = "Test";
CDC pDC;
pDC.CreateCompatibleDC((CDC*)::GetDC(NULL));
pDC.SetBkMode(TRANSPARENT);
pDC.SetTextColor(RGB(0,0,0));
CRect bmpRect(0,0,0,0);
CSize sz = pDC.GetTextExtent(sText, sText.GetLength());
bmpRect.SetRect(0, 0, sz.cx + 4, 15);
int nXPos = (int)((bmpRect.Width() - sz.cx) * 0.5);
CBitmap bmp;
bmp.CreateCompatibleBitmap(&pDC, bmpRect.Width(), bmpRect.Height());
pDC.SelectObject(&bmp);
CFont bmpFont;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
strcpy(lf.lfFaceName,"Arial");
lf.lfQuality = NONANTIALIASED_QUALITY;
lf.lfHeight = 8;
lf.lfWeight = 100;
bmpFont.CreateFontIndirect(&lf);
CFont* pOldFont = pDC.SelectObject(&bmpFont);
CBrush bmpBrush;
bmpBrush.CreateSysColorBrush(COLOR_BTNFACE);
CBrush* pOldBrush = (CBrush*)pDC.SelectObject(&bmpBrush);
pDC.Rectangle(&bmpRect);
pDC.TextOut(nXPos, 2, sText);
pDC.SelectObject(pOldBrush);
pDC.SelectObject(pOldFont);
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
From just a quick reading (I didn't run it either ) it looks almost right. The only thing that looks wrong is
pDC.CreateCompatibleDC((CDC*)::GetDC(NULL)); You're casting a HDC to a CDC* , which is a bad cast since those two aren't the same thing. Use CDC::FromHandle() instead.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but how will we fit the hamster inside the accordion?
|
|
|
|
|
Hi,
I'm able to make static controls transparent but I ran into some problems with check boxes. There background is black!
Here's some code:
<br />
LRESULT CDlgAntiFraudWarning::OnCtlColorDlg(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
SetBkMode( (HDC)wParam, TRANSPARENT );<br />
return (LRESULT)m_hBrushBkgr;<br />
}<br />
<br />
LRESULT CDlgAntiFraudWarning::OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
SetBkMode( (HDC)wParam, TRANSPARENT );<br />
return (LRESULT)m_hBrushNull;<br />
}<br />
<br />
LRESULT CDlgAntiFraudWarning::OnCtlColorBtn(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
SetBkMode( (HDC)wParam, TRANSPARENT );<br />
return 0;<br />
}<br />
What's the solution? Thanks!
|
|
|
|
|
hello,
I just want to know how to make a string an hyperlink to an http page without using MFC, I founded here and on codeguru some example but they're for MFC code...
thanks
Paolo
|
|
|
|
|
On XP and 2003 there is a built-in hyperlink control. On previous OSes you can use WTL's CHyperLinkCtrl .
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
can you please tell me how it's called and how I can apply it to a dialog box??,
I'm unable to find it into Visual Studio's Toolbox
Thanks
Paolo
|
|
|
|
|