|
Hi All,
I am filling numbers in a listBox.
for(int i =;i<20;i++)
{
CString string;
string.Format(i);
ListBox.Addstring(string);
}
the output is like
0
1
10
11
12
..
..
..
..
19
2
3
4
5
6
7
8
9
Can anypne tell how to get the numbers in order and not like this..
|
|
|
|
|
Hi hraman,
Remove the 'sort' style of your list box and everything will be alright.
Best Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi
I used a while loop and i am having the same problem
while(i<20)
{
CString string;
string.Format(i);
ListBox.Addstring(string);
++i;
}
Can u please be bit detailed on what u mean by Sort?
Thanks!!!!
|
|
|
|
|
By default, Visual Studio sets the LBS_SORT style (forcing alphabetic sort) when adds a Listbox control to your window. To remove it, in the Resource View pane, select the Listbox and then set the Sort property to False .
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]
|
|
|
|
|
Thanks a lot .. i changed it and now its working fine
Thanks
|
|
|
|
|
You are welcome.
BTW: I really don't know why they think alphabetic sort should be the default.
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]
|
|
|
|
|
CPallini wrote: BTW: I really don't know why they think alphabetic sort should be the default.
As opposed to what?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
No sort.
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]
|
|
|
|
|
Another approach would be to left-pad the numbers with a 0 . That may go against your design, however.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I made layered window which is base dialog. I put on the sub dialog upper layered window, but base dialog flashes by itself.
what's problem??
sample coude : http://zoo.wo.tc/test1234.zip
thank you.
|
|
|
|
|
Hi. Well... I'am trying to make my own transparent button, but i need to rotate it to. I tryed to use SetWorldTransform function to make a rotation, but it results in clean dialog. Pls tell me what do i do wrong?
void MPictureBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC;
pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
m_rtfmdc = new CDC;
m_rtfmdc->CreateCompatibleDC(pDC);
m_rtfmdc->SelectObject(m_bmp);
int Rotate=1;
XFORM xf = {0,1,-1,0,0,0};
int OldMode = SetGraphicsMode(*pDC,GM_ADVANCED);
SetWorldTransform(*pDC,&xf);
switch (MBStyle)
{
case MBUT_TRANSPARENT:
pDC->TransparentBlt(0,0,ButSize,ButSize,m_rtfmdc,ButSize*ImageNumb,0,ButSize,ButSize,RGB(0,0,0));
break;
case MBUT_SOLID:
pDC->BitBlt(0,0,ButSize,ButSize,m_rtfmdc,ButSize*ImageNumb,0,SRCCOPY);
break;
default:
MessageBoxA("Nepravilnie parametri prozrachnosti");
}
SetGraphicsMode(*pDC, OldMode);
m_rtfmdc->DeleteDC();
m_rtfmdc=NULL;
}
|
|
|
|
|
|
|
Hi
I designed (using VS class wizard) a class which was derived from CWnd. I did following in my View.
The Create function will return "0". According to MSDN, it failed.
pRulerX = new CRuler();
int ret = pRulerX->Create(_T(""), _T("rulerx"), WS_CHILD | WS_VISIBLE, CRect(0, 0, pRulerX->RulerHeight, pRulerX->RulerHeight), this, 55355);
From debug:
ret = 0;
pRulerX's m_hWnd is "NULL"
Thanks,
|
|
|
|
|
_T("") is different from NULL or 0 .
The first parameter of Create can be NULL or 0 , but not _T("") .
Just to add, hope you have valid values for pRulerX->RulerHeight and pRulerX->RulerHeight .
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
I changed as following:
int ret = pRulerX->Create("CRuler", "rulerx", WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), this, 55355);
the "ret" is still "0".
|
|
|
|
|
If you look at the documentation of CWnd::Create[^] you will see that the first parameter of Create must be either NULL or a name that is registered using the AfxRegisterWndClass function or one of the predetermined class names.
Try this -
int ret = pRulerX->Create(0, "rulerx", WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), this, 55355);
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)
|
|
|
|
|
It works. Thank you so much.
|
|
|
|
|
Hello everybody,
My question is if it is possible for a MFC application to use a theme, different from the theme of the Windows itself e.g the application to use "Windows XP" theme (or some modified theme) and the Windows to use "Windows Classic" theme. If there is some way of doing that I would appreciate a clue or two =].
Greetings, Peter
|
|
|
|
|
There are a lot of samples in codeproject talking about this topic. Just search for it using key word "theme".
VS 2008 can generate this type of application.
|
|
|
|
|
I know how to access system Image list using this function
HIMAGELIST GetSystemImageListOfSmallIcons()const {
HIMAGELIST himl;
SHFILEINFO sfi;
himl = (HIMAGELIST) (::SHGetFileInfo( _T(""), 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_SMALLICON));
return himl;
}
but is there any way ,that i could access to special icons like "My Document" Folder icon or "Contacts" Folder Icon or even "My Computer" Icon of the operating system.
|
|
|
|
|
Hmm, maybe try with SHGetFileInfo[^] along with SHGetFolderLocation[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
So would you suggest a code which I could get My computer Icon or My network places Icon?
|
|
|
|
|
This should get you the MyComputer icon:
HICON GetMyComputerIcon()
{
HICON Icon = NULL;
LPITEMIDLIST IDPath;
if (SUCCEEDED(SHGetFolderLocation(m_hWnd, CSIDL_DRIVES, NULL, 0, &IDPath)))
{
SHFILEINFO Info = {0};
if (SHGetFileInfo((LPCTSTR)IDPath, 0, &Info, sizeof(Info), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_PIDL)) Icon = Info.hIcon;
ILFree(IDPath);
}
return Icon;
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|