|
I've got some questions regarding the CImageList:
initialisation code:
m_pImageList=new CImageList();
m_pImageList->Create(16,16,ILC_COLOR8,0,4);<br>
m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_ICON_FOLDER_DESELECTED));
m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_ICON_FOLDER_SELECTED));
m_pImageList->SetBkColor(CLR_NONE);<br>
m_ctrlTree.SetImageList(m_pImageList,TVSIL_NORMAL);
population code:
m_hTreeItem=m_ctrlTree.InsertItem(TVIF_TEXT,lpszName,0,1,0,0,0,m_hParentTreeItem,NULL);
2 questions:
I've used 256-color transparent icons, but they show up with a black background, although my treecontrol has a white background. Why? Do I have to use bmp instead?
It will always show the first icon, whether the node is selected or not. Why? Do I have to do a special repaint when a node is selected?
tnx.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
sorry, too quick...
I've added TVIF_SELECTEDIMAGE next to TVIF_TEXT
Yet the background...
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
Hi,
I'm trying to control the number of values displayed after the decimal point in a CString. I have a variable which holds the number of values I wish to see after the decimal point. Is there any way of using this variable in the Format method? So rather than having:
x.Format(_T("%.5f"), number)
I would like the 5 ( or whatever number ) to be replaced by my variable.
Thanks.
|
|
|
|
|
CString s;
s.Format("%%.%df", 5")
s.Format(s, .2346324523);
The idea is that the double %% gets turned into a single one, and the single one gets used to put your value in.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I keep getting a run-time error.
My code is:
strx.Format(_T("%%.%f"), signif);
strx.Format(strx, m_nMolarity);
where signif is the variable that I want to use to specify the number of decimal places after the point and m_nMolarity is the variable which requires formatting.
Have I misinterpreted your code?
Thanks
|
|
|
|
|
You lost the d.
"%%.%df", signif formats to
%.5f if signif = 5;
then format that with m_nMolarity.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
What a cunning stunt! I'm very impressed.
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
Yo've missed one little thing:
You have: "%%.%f" , and You should have "%%.%df"
And of course signif must be an integer value;
"%%.%f" tries to interpret your signif as floating poin value and it doez not produce the f char for m_nMorality.
"%%.%df" will produce "%.<signif>f"
[ CoY0te ]
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
Hi,
The easiest way to do this is to use the '*' modifier in your format string. This allows you to specify the number of digits with a variable.
The following will format using a variable number of digits:
int precision = 5;
x.Format( _T("%.*f"), precision, number );
You can also use a * for the width of the field, so the following will set the width and precision:
int width = 10;
int precision = 3;
x.Format( _T("%*.*f"), width, precision, number );
Best regards,
John
|
|
|
|
|
Hello
I'm having some problems with byte alignment. I'm writing a graphics editor for particle effects for games. The effects are edited on a PC and exported to a file which is read by a PlayStation2. The code for the PS2 is compiled under GCC, the editor with VC++ 6.0 (Service Packs installed).
For memory reasons I want to be able to use the file I load as the structure directly, so it must be stored witht the correct byte alignment to be correctly read by the PS2 (and to benefit from possible later VPU optimisations). I have set the VC++ project settings to be 16 byte aligned by default. I have also used #pragma pack(16) before critical structures.
I noticed however that for some x87 asm I wrote that the structures were not being 16 byte aligned. VC++ seemed to be completely ignoring ALL my efforts to force it to align structures.
Now when reading the structure, if I tell gcc that the structure is 16-byte aligned (using the __attribute__(align(16)) directive) the structure is read incorrectly. If VC++ had written my structure with 16 alignment this should not be the case? However when I switch off the alignment directive on gcc the struct is loaded correctly.
My questions are:
1)
How can I declare a structure in VC++ such that it will have specific alignement? I think it is as follows:
#pragma pack(16) or #pragma pack(push,16) followed by #pragma pack(pop) bracketing the struct declaration. But my experience seems to be to the contrary.
2) How can I check this is actually working?
3) How can I check the alignment of a pointer at runtime?
If anyone has any experiences in this area, and want to tell me about them, please do!
Thanks to anyone who helps,
- solosnake
|
|
|
|
|
Can you check the size of your struct with sizeof at runtime?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Yes I can, by creating a temporary and examining. Is the idea to see if it changes in VC++ when I change alignment? I'll give it a go.
- solosnake
|
|
|
|
|
In my code I use
#define CACHE_LINE 32<br />
#define CACHE_ALIGN __declspec( align(CACHE_LINE) )
to align a variable on the 32byte boundry so that it is AGP cache aligned (I'm writing a game at the mo.). Change the above to 16. Should work.
BTW, how is the Linux Kit for the PS2? Is it any good? I'm thinking of getting it but I'm currently too busy with Opengl to get a crack at the PS2.
bibamus, edamus, cras moriemur [eat, drink, for tomorrow we die]
|
|
|
|
|
Disclaimer: The following statement is not exactly true, but it's close enough for the purpose of this discussion.
#pragma pack only affects the packing of things larger than the specified size. Things smaller than the specified size are packed on their natural boundaries. For example, pragma pack(2) will cause ints, longs and __int64s to be packed on 2-byte boundaries, but won't affect the packing of chars (one-byte boundaries) or shorts (2-byte boundaries in any case).
Perhaps if you were to show us your structure, we'd be able to tell you why you are not getting the expected results.
Under the circumstances, you may want to use pragma pack(1) and put explicit padding in your structure.
|
|
|
|
|
Hello
This structure causes problems when the PFXVector3 struct is declared with __attribute__(align(16)) in gcc, even when VC++ is set to align on 16 byte boundries.
struct PFXVector3 {<br />
F32 x,y,z;<br />
};<br />
<br />
struct PFXEffectBaseData {<br />
U32 m_uiLifeTime;<br />
U32 m_uiAge;<br />
U32 m_uiFlags; <br />
CMatrix4 m_matrixRotate;<br />
PFXVector3 m_v3dGravity;<br />
PFXVector3 m_v3dPosition;<br />
};
U32 is just a typedef for unsigned 32 bit ints.
F32 is typedef for 32 bit single prec. fp.
CMatrix4 is the house matrix class.
To Brian:
>BTW, how is the Linux Kit for the PS2? Is it any good? I'm thinking of getting it but I'm
>currently too busy with Opengl to get a
>crack at the PS2.
I'm using SN Systems and a genuine Sony Dev Kit here at work. But sometimes I wish I was at home with a Linux Kit And doing OpenGL....sigh....
Thanks for all feedback again to everyone
- solosnake
|
|
|
|
|
1.
I've CEdit and a CButton on a CDialog. The CButton placed on top of the
CEdit. When the CButton is dragged up/down, I wish the CEdit will
streach/shrink, corresponding to the CButton bottom coordinate.
CAN SOMEONE LINK ME TO SOME ARTICLE THAT CAN RESOLVE MY ISSUE???
2.
An article dealing with HOWTO create non-cubical windows/controls (please?)
10XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX a lot
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
Hi,
Can any one tell me the API's for database connection with SDK. Is there any article which explains this.
Kindly help.
|
|
|
|
|
I do not believe Windows SDK provides any database connection functionality. You will have to use the ODBC SDK at minimum or native drivers/tools provided by the DBMS vendor or newer connectivity tools likes ADO, OLE DB etc. I am assuming when you said SDK you meant Windows SDK.
|
|
|
|
|
Hi,
If you use Access, you can use CDao* classes.
hope it helps !
|
|
|
|
|
After having used CListCtrl::FindItem() to find the index of an item I want to mark the row with that index how do I do that?
I also committed the crime of posting a programming question in the Lounge.
|
|
|
|
|
To select item number i in list control use:
m_list_ctrl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
To ensure that item number i is visible, use:
m_list_ctrl.EnsureVisible(i, FALSE);
If you want full row selection in list control:
m_list_ctrl.SetExtendedStyle ( LVS_EX_FULLROWSELECT );
|
|
|
|
|
Mark?
If you by "mark" mean "select" then use the SetCurSel(index) method
|
|
|
|
|
Argh! Ignore my previous post, too early in the morning...
|
|
|
|
|
Hi
Can someone explain PeekAndPump() function and why should we use it with a ProgressBar??
Is there a standard definition for this function???
|
|
|
|
|
Good link http://www.codeguru.com/controls/progress_wnd.shtml
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|