|
If i understand u correctly u want to add an icon for ur tree component.
U can choose between the two function i worked on before.
the first function is for getting the icon from ur computer(The one specified in the folder option FileTypes Tab)
HICON CMyTreeCtrl::GetIcon(CString pathFileName)
{
// Call SHGetFileInfo to get the icon. Call with dummy filename and
// SHGFI_USEFILEATTRIBUTES flag, so file doesn't actually have to
// exist.
SHFILEINFO shfi;
memset(&shfi,0,sizeof(shfi));
SHGetFileInfo(pathFileName,
FILE_ATTRIBUTE_NORMAL,
&shfi,
sizeof(shfi),
SHGFI_ICON|
SHGFI_USEFILEATTRIBUTES|
SHGFI_SHELLICONSIZE |
SHGFI_SMALLICON);
return shfi.hIcon;
}
And the second one if u want to customizeur own images:
First create the icons then Create an imagelist and do the following
m_imageList.Create(16,16,0,3,2);
m_imageList.SetBkColor(RGB(255,255,255));
HICON hIcon;
hIcon = AfxGetApp()->LoadIcon(IDI_ICON2); //Folder eg
m_imageList.Add(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ICON3); //File eg
m_imageList.Add(hIcon);
m_T.SetImageList(&m_imageList,TVSIL_NORMAL);
I hope this helps
/\|-||\/|/\|)
|
|
|
|
|
Thanks for your reply.
What exactly my problem is when i clicked the LARGE ICON Button on the applications tool bar or select it from the View menu the Icons are not getting displayed in the List view. I am able to see the icons in other views namely Details,Small Icons ,Lists. There's absolutely no problem with the tree view.
|
|
|
|
|
I think you probably didn't load/set icons for large view, did you?
- NS -
|
|
|
|
|
How to arrange message sending and getting for example in MDI windows forms app I need to send a custom message WM_USER+1 or something from child to parent and to get it in parent. Something like in VC++ ON_MESSAGE(...) macro is it possible in windows forms, please give a snippet of code
9ine
|
|
|
|
|
9ine wrote:
. Something like in VC++ ON_MESSAGE(...) macro is it possible in windows forms, please give a snippet of code
you will get Quicker response if you post your question here Managed Forms[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Not sure if this applys to win forms but this works for VC6, Check this link out.
http://flounder.com/messages.htm[^]
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
hey...
for my graph application i want to read a text file which contains integers(coordinates) looking somewhat like this....
123 67
45 23
76 100
.....file has 1000 such pairs
it works well if start from the beginning.
since i have to access the file randomly depending on the value of a variable 'x'....x is basically the pair from where u want to start plotting till the end.... and using fseek()
fseek(fp,x,SEEK_SET)
but since fseek() positions by calculating the no. of bytes from origin i am having trouble positioning the pointer at the appropriate place..
need help and plz also clear the concept 'no. of bytes from origin '
thanks
|
|
|
|
|
no. of bytes from origin: the number of single character objects from the start of the file. Note on text files under windows, this sometimes includes CRLF combos of two characters to mark an end of line.
well, depending on how you want to do this. Read through each pair with fgets() storing the starting point of each pair with ftell() before each read, in an array of 1000 long integers. This provides an index to the text file that you can seek to.
Alternately, you can rewrite the file to binary, takes up less space and each integer has a known size (1,2,4,8 byte integers depending on what you want to use), or pad the text file with spaces to a known size.
If it were my software, I wouldn't randomly seek through a file that small, load the whole file in memory. But I figure that means this is probably a homework assignment. which is why my message ends here. good luck.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Raza5680 wrote:
123 67
45 23
76 100
It's hard to compute the correct offset for a given pair, because the numbers aren't padded (or at least don't seem to be in your post) and thus each pair may have a different length. If you control the creation of the file too, you might convert it to something like
123 067
045 023
076 100
With that format, the byte length of each pair can be computed as
int PairLength()
{
return = 3
+ 1
+ 3
+ 2;
}
Then, the byte offset for pair x (assuming it's a zero-based index) would be
int PairOffset(int x)
{
return (x-1)*PairLength();
}
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
How do i programmatically create a system restore point and then later restore from that point on ?
i found the example code in msdn implement by vbscript,using WMI
could you tell me how to implement it in VC?
thanks
I love programming
|
|
|
|
|
Hi, Hope below function elps U.
========================================================
HRESULT CreateRestorePoint(void)
{
RESTOREPOINTINFO RestPtInfo;
STATEMGRSTATUS SMgrStatus;
// Initialize the RESTOREPOINTINFO structure
RestPtInfo.dwEventType = BEGIN_SYSTEM_CHANGE;
// Notify the system that
// An application is to be installed.
RestPtInfo.dwRestorePtType = APPLICATION_INSTALL;
// Set RestPtInfo.llSequenceNumber.
RestPtInfo.llSequenceNumber = 0;
// String to be displayed by System Restore
strcpy(RestPtInfo.szDescription, "New Restore Point");
// Notify the system that changes are to be made and that
// the beginning of the restore point should be marked.
if(!SRSetRestorePoint(&RestPtInfo, &SMgrStatus))
{
cout<<"Couldn't set the restore point as it is disabled !\n";
return(HRESULT_FROM_WIN32(SMgrStatus.nStatus));
}
// When the call succeeds, the SmgrStatus, llSequenceNumber
//wil have the sequence number for the restore point.
// The application should perform some installation
// operations here.
// Re-initialize the RESTOREPOINTINFO structure to notify the
// system that the operation is finished.
RestPtInfo.dwEventType = END_SYSTEM_CHANGE;
// End the system change by returning the sequence number
// received from the first call to SRSetRestorePoint()
RestPtInfo.llSequenceNumber = SMgrStatus.llSequenceNumber;
// Notify the system that the operation is done and that this
// is the end of the restore point.
if(!SRSetRestorePoint(&RestPtInfo, &SMgrStatus))
{
cout << "Couldn't set the end of the restore point."<
|
|
|
|
|
Hi all:
My listctrl has a BMP background and one of its subitem has icon.
What the problem is that the subitem which has icon only looks transparent againt listctrl BK when the system under the default setting for "window color" which is white, once I change the default setting the subitem not transparent anymore, what's the cause?
|
|
|
|
|
How are you creating the ImageList? How are you adding the images to it? Are you adding icons or bitmaps?
I'm not sure, but your problem might be because your image list isn't a masked one.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
How are you creating the ImageList?
m_imgSmallList.Create(16, 16, ILC_COLORDDB | ILC_MASK, 6, 1);
bitmap.LoadBitmap(IDB_COMMON_ICON);
m_imgSmallList.Add(&bitmap, RGB(255, 255, 255));
Jose Lamas Rios wrote:
Are you adding icons or bitmaps?
Adding bitmaps here
|
|
|
|
|
I can't see anything wrong, unless the bitmap isn't using an exact white for the areas intended to be transparent...
Just a wild guess, but try calling SetBkColor(CLR_NONE) on the list control and see if it makes any difference.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
No difference spotted!
After little study, I found out that the LVS_EX_FULLROWSELECT and LVS_EX_SUBITEMIMAGES seems to be mutual exclusive regarding the problem I just stated!For transparency If I specify the former property then the subitem image must be removed, If I specify the later property then the full row select property must be romoved!How come?
|
|
|
|
|
Here's the code snippet I used to populate the list control!
m_cListCtrl.DeleteAllItems();
m_cListCtrl.SetExtendedStyle(LVS_EX_SUBITEMIMAGES );
m_cListCtrl.SetTextBkColor(CLR_NONE);
LVITEM lvi;
CString strItem;
for (int i = 0; i < m_nItems; i++)
{
lvi.mask = LVIF_IMAGE | LVIF_TEXT;
strItem.Format(_T("Item %i"), i);
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
lvi.iImage = i%8;
m_cListCtrl.InsertItem(&lvi);
strItem.Format(_T("%d"), 10*i);
lvi.iSubItem =1;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
lvi.iImage = i%8;
m_cListCtrl.SetItem(&lvi);
strItem.Format(_T("%s"), COleDateTime::GetCurrentTime().Format(_T("Created: %I:%M:%S %p, %m/%d/%Y")));
lvi.iSubItem =2;
lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
m_cListCtrl.SetItem(&lvi);
}
Leave the line #2 comment there transparency was gained, once comment out it, the subitem with icon is not tranparent!But the question is I want the both list properties!
Pls note: The system is not under default "window color"!
Same problem happens regardless what the system "window color" is!
|
|
|
|
|
YongSheng Li wrote:
m_cListCtrl.SetTextBkColor(CLR_NONE);
Just in case, what I suggested was SetBkColor . Did you try with that too?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
what I suggested was SetBkColor
m_cListCtrl.DeleteAllItems();
m_cListCtrl.SetTextBkColor(CLR_NONE);
m_cListCtrl.SetBkColor(CLR_NONE);
Is that what you recommanded!
The problem remains, All the subitem with icon still opaque and consistent the system "window color"!
|
|
|
|
|
YongSheng Li wrote:
Is that what you recommanded!
Yes.
YongSheng Li wrote:
The problem remains, All the subitem with icon still opaque and consistent the system "window color"!
All right, I'm lost. I can't think of anything else to try...
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
All right, I'm lost. I can't think of anything else to try...
Thank you!anyway!
|
|
|
|
|
hI guys..
i have a bit of back ground in c and now is given a project on vbC++.. i was suppose to create a program for my com to connect to a PLC(programmeable logic control) the progam is suppose to give me the status on the relay swithces status for my plc.. Any idea guys on how to start doing it?
|
|
|
|
|
cue_ball wrote:
i have a bit of back ground in c and now is given a project on vbC++..
Is that VB or VC++ ? What version of VC ?
cue_ball wrote:
i was suppose to create a program for my com to connect to a PLC(programmeable logic control) the progam is suppose to give me the status on the relay swithces status for my plc..
How does it connect to the PC ? If via parallel or serial ports, there are articles on this site on how to listen/speak to both of these.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
IT visual c++..
im using vc++ 6.0
|
|
|
|
|
And the interface to this device ?
Christian Graus - Microsoft MVP - C++
|
|
|
|