|
If you are sharing a global variable, then you must share the critical section as well. Each function must lock the same critical section, otherwise they don't do anything. So you'll have to define it as extern if it's used in multiple files.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I am stuck up with a small problem. I am making an application (Explorer style), where there is a ROOT NODE, various PARENT NODES below it & CHILD NODES below PARENT NODE.
The problem is that the tree is kindof hardcoded, means there is no registery or file or database to read form & populate the tree. I know what all nodes are there and their hierarchy & have to populate the tree at startup.
But at the same time I have to make the code as generic as possible so that in furture it should be easy to add a new node at any level.
Is there some way to generalize this ?
Or for every item I will have to go through the painfull process of "LoadIcon", "Add" & "InsertItem"
|
|
|
|
|
Well you need two things. Somewhere to store the information so that it can be edited easily and a mechanism to read that data and populate the tree. This could happen at runtime or at build time by generating code from the data.
You could store the data in the registry, an xml file, a custom format text file, a database etc etc
If you go with a runtime solution then you run the risk that the user will modify the data, if you do it at build time you dont have that problem.
Why dont you make a function that calls LoadIcon, Add, InsertItem etc and just call that. Then you would only need to add extra calls to this function to add extra items
|
|
|
|
|
Thankx. I am working on this solution but the problem is that for this I had to make a "array" having the following elements;
UINT iResourceId; // Resource ID used in LoadIcon
UINT iMask; // Used in TVINSERTSTRUCT
char strNodeText[20]; // Used in TVINSERTSTRUCT
bool bChildPresent; // Used in TVINSERTSTRUCT
tTreeNodeEnum eTreeNodeEnum; // Unique value passed in lParam of
// TVINSERTSTRUCT, to detect which node is
// clicked
There are 2 problems to this approach.
1) Population of the array at start-up
2) I still have to keep a track of the parent nodes & the childs within the parent node. coz u have to pass a parent handle to the TVINSERTSTRUCT.
Any comments / suggestions ?
|
|
|
|
|
Im happy to help on the condition that you attempt to use the English language correctly. Thankx is not a word, nor is it an abreviation of any word in the English language. In fact its not an abreviation at all.
Now the rant is over....
a few questions...
1) why do you need the mask in the structure? If you are adding text and an image everytime the mask will be constant.
2) why do you need to know if it has children? I think you need to know if it has a parent
3) why not use CString and not char strNodeText[20]? to be really picky why is it called strNodeText? text would be fine. The node part is implied by the fact its a member of a class or struct that represents a node. The data type is implied by the word text so str is not required (i really hate hungarian notation)
4) tTreeNodeEnum.... what is this? I suspect its not required.
Why dont you have something like this
UINT id;
UINT parentId;
UINT iconResourceID;
CString text;
UINT order;
where id is just a unique number that you assign. This allows you to represent your tree structure in your data.
You could store this data in an xml file and the parentId would not be required as the tree structure would be represented by the xml. Same with the registry
Hope this helps
|
|
|
|
|
mavrick23 wrote:
Is there some way to generalize this
XML works great as a data source for tree controls.
But, that's just my opinion... I could be wrong.
Hate is not a family value.
-pete
|
|
|
|
|
i have created a status bar in my dialog based application.
the code is below:-
#define IDC_STATUSBAR 32000 //resource id
CStatusBarCtrl m_StatBar;
BOOL m_bStatOK = m_bStatBar.Create(WS_CHILD | WS_BORDER | WS_VISIBLE, rect, this, IDC_STATUSBAR);
m_StatBar.SetText("Application Running",0,0);
The program is running fine. the text is shoen on the left hand side of the status bar. Now i want to display another text on the right hand side of the statusbar. how do i do? i tried by inserting the statement
m_StatBar.SetText("Time",255,0);
But it had no impact?
how do i proceed
|
|
|
|
|
You have to first define your panes.
You will need 3 panes, one for the text on the left, one for the text on the right and one to act as a seperator.
Call CStatusBar::SetIndicators() to define the number of panes and the id for each
Then call CStatusBar::SetPaneInfo() for the seperator and give it the SBPS_STRETCH style. This will cause the seperator to fill all the unused space between the panes
|
|
|
|
|
im using mySQL and i have a problem on how to call BLOB into visual C++/MFC..the syntax and any declaration needed..
|
|
|
|
|
Hi..Check out..codeproject site..
A aritcle is there for saving BLOB data..use that method..that is applicable to all database...
Bye..Have fun..
Never consider anything Impossible before trying to solve that..---Sumit Kapoor---
|
|
|
|
|
How do you display an open/save dialog in MFC and get the file path/s that was/were selected?
|
|
|
|
|
Have a look at CFileDialog
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Try using this code:
CFileDialog fileDlg(TRUE);
if(fileDlg.DoModal() == IDOK)
{
CString strFileName;
fileDlg.GetPathName();
MessageBox(fileDlg);
}else{
MessageBox("No file selected!");
}
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
Hai,
I'm doing a dialog application in win32. I have several static labels in my dialog. I'm doing a sequence of drawing and once I finish the sequence ,I Invalidate my whole dialog to erase all my drawings. When I do this my first label alone disappears and later in the application when I do again Invalidate Rect then it appears.What's the problem here? I'm not using that static label(which dissapears) anywhere in my program. It is just there as a label.What did I miss? Thanks a lot.
|
|
|
|
|
Hai,
I'm doing a dialog application in win32. I have several static labels in my dialog. I'm doing a sequence of drawing and once I finish the sequence I Invalidate my whole dialog to erase all mt drawings. When I do this my first label alone disappears and later in the application when I do again Invalidate Rect then it appears.What's the problem here? I'm using that static text anywhere in my program. It is just there as a label.
What did I miss? Thanks a lot.
|
|
|
|
|
I need to be able to detect CD Burning devices, but after searching for some time now I'm still not sure how to get the information I need.
I need to be able to detect that there is indeed a device that can burn to CD-R/CD-RW (be is a CD burner, or a DVD burner than supports burning CDs too). What I *really* need is the drive letter for that device.
I do not actually need to do any burning, I simply need to detect that one exists and report the drive's letter.
If you have any ideas that will save me from Google-Hell, please let me know!
Thanks!
: Dean
: Dean 'Karnatos' Michaud
|
|
|
|
|
Dean `Karnatos` Michaud wrote:
I need to be able to detect CD Burning devices...
Have you looked at the Win32_CDROMDrive and Win32_PhysicalMedia WMI classes?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hi
i'm trying to use this package for my program: http://www.codeproject.com/miscctrl/pgllib.asp
can any one give me an idea how should i do add it? i did download it in my c drive but don't know how to use it
sorry i'm new
really thank you
|
|
|
|
|
Oriocat wrote:
can any one give me an idea how should i do add it?
Did you not read the "Installation" and "Getting your project started" sections of that article?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I did i have GDI+ and don't know ehre to find Gdiplus.dll. also i can't recompile the source which i'm not sure why
really thank you
|
|
|
|
|
Oriocat wrote:
...don't know ehre to find Gdiplus.dll.
Have you looked for it? On my machine, it's in the c:\winnt\system32 folder.
Oriocat wrote:
i can't recompile the source...
Which tells us nothing. What compiler/linker errors are you getting? What do the lines in error look like?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Oriocat wrote:
also i can't recompile the source which i'm not sure why
I am almost certain you need a compiler for that.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
1. How can I drag my dialog when draging over a certain portion of the dialog??? When I'm using:
UINT CNBinderDlg::OnNcHitTest(CPoint point)
{
UINT ret = CDialog::OnNcHitTest(point);
if(ret == HTCLIENT)
{
return HTCAPTION;
}
return ret;
}
I can drag the window by draging anywhere in the window.
2. Is it posible to hide or lock a directory, not only in explorer(with ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}") but in other file managers like TotalCommander too??? Thanx!
|
|
|
|
|
1. Easily.
As you can see in the WM_NCHITTEST message handler, you receive a CPoint object that specifies the point, in screen coordinates, where the hit test was made. If you first use ScreenToClient function to convert the CPoint into client coordinates then you can compare the coordinates to a pre-made list of where the function should return HTCAPTION . Everywhere where HTCAPTION is returned, the dialog becomes draggable.
Thus, if, for example, the x-coordinate of the CPoint is smaller than a half of the dialog's width, then you return HTCLIENT . Otherwise you return HTCAPTION . As a result, when you click and hold on the right-most half of your dialog, it can be dragged.
2. Some advanced file managers by-pass the security settings placed in the registry. To go around this, you could try the _access and _waccess functions of the Run-Time C Library. Not sure if they work though...
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
...you could try the _access and _waccess functions...
These are "get" functions not "set" functions, or did I miss your intent?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|