|
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
|
|
|
|
|
|
Hi,
I am trying to get the IPv6 address. I am using following code.
IP_ADAPTER_ADDRESSES ipadd;
ULONG buflen;
DWORD err;
memset(&ipadd, 0, sizeof(ipadd));
err=GetAdaptersAddresses(AF_INET6,GAA_FLAG_SKIP_DNS_SERVER,NULL,&ipadd,&buflen);
but whenever the code is executed the application close down without any error.
I am compiling this by using WinXP SP2 SDK and using VS 6.0
Please Reply
Regards
Alpha
|
|
|
|
|
How about:
IP_ADAPTER_ADDRESSES *ipadd;
ULONG buflen;
GetAdaptersAddresses(AF_INET6,GAA_FLAG_SKIP_DNS_SERVER,NULL,NULL,&buflen);
ipadd = new IP_ADAPTER_ADDRESSES[buflen];
GetAdaptersAddresses(AF_INET6,GAA_FLAG_SKIP_DNS_SERVER,NULL,ipadd,&buflen);
...
delete [] ipadd;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
Thanx for reply It's working now. But I don't really know I am not getting the desired output. It shows all return values in box junk characters.
for example the code
CString strFinal;
IP_ADAPTER_ADDRESSES *ipadd;
ULONG buflen;
GetAdaptersAddresses(AF_INET6,GAA_FLAG_SKIP_DNS_SERVER,NULL,NULL,&buflen);
ipadd = new IP_ADAPTER_ADDRESSES[buflen];
GetAdaptersAddresses(AF_INET6,GAA_FLAG_SKIP_DNS_SERVER,NULL,ipadd,&buflen);
strFinal.Format(L"Name of Adapter %s",ipadd->AdapterName);
delete [] ipadd;
The ipadd->AdapterName returns value in junk character.
Thanks for reply
Regards
Alpha
|
|
|
|
|
Alpha Siera wrote:
strFinal.Format(L"Name of Adapter %s",ipadd->AdapterName);
Just curious, but since you are using Unicode, shouldn't that %s be a %S instead?
I don't have Windows XP Pro or Windows .NET Server so I cannot test your code snippet.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Was a linkedlist.obj file produced?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
below is the output & there object files for all source files.
Compiling...
linkedlist.cpp
-+- COMPILING i:\program\user\richard millen\source\_dev\list_test\list_test\linkedlist.cpp
-+- COMPILING i:\program\user\richard millen\source\_dev\list_test\list_test\linkedlist.h
-+- COMPILING i:\program\user\richard millen\source\_dev\list_test\list_test\linkedlist.h
main.cpp
-+- COMPILING i:\program\user\richard millen\source\_dev\list_test\list_test\main.cpp
-+- COMPILING i:\program\user\richard millen\source\_dev\list_test\list_test\linkedlist.h
-+- COMPILING i:\program\user\richard millen\source\_dev\list_test\list_test\linkedlist.h
i take it linkedlist.h is being run through the compiler twice because there are 2 classes in there (linkedlist & listelement)!?
|
|
|
|
|
Is there a way in a CFormView-based class to get a control by it's id like GetDlgItem() that returns a (CWnd*)
[insert witty comment here]
bdiamond
|
|
|
|
|
bdiamond wrote:
Is there a way in a CFormView-based class to get a control by it's id like GetDlgItem() that returns a (CWnd*)
You may need to rephrase this question , but you have just answered your own question. GetDlgItem() should work as described in any CFormView class.
I Dream of Absolute Zero
|
|
|
|
|
Can someone point me in the right direction for creating a download progress dialog while an activeX control is installing. I presume it's some kind of callback but would appreciate some help. (examples)
thanks in advance
Carl
|
|
|
|
|
Hi, I've got a need to include an .exe inside a dll. Basically the dll is downloaded from a web site and needs to copy (unpack) the .exe to a destination directory. My first thought is to include it as a custom resource. Before going down that road i would like to know if anyone can offer a better solution?
thanks - Carl
|
|
|
|
|
There's nothing wrong with your approach. See here for an example.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks David! - just what i was looking for
One question...
Do you know if this could be done with an activeX control? (MFC based)
I'm going to try it but wondered if you might know.
Carl
|
|
|
|