|
Hi,
I am doing a project in win32 vc++...dialog based app..
I am getting a string from the user. It is a path. I want to check whether the string is a valid path. Is there any function to check that..
thanks.
|
|
|
|
|
try the function I use
BOOL FileExists(CString strFolderName)
{
return GetFileAttributes(strFolderName) != INVALID_FILE_ATTRIBUTES;
}
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Keep in mind that the previous solution will be true for folders AND files.
This one is true only for folders:
BOOL DirectoryExists(CString strFolderName)<br />
{<br />
BOOL bDirectory = FALSE;<br />
<br />
DWORD dwAttributes = GetFileAttributes(strFolderName);<br />
<br />
if( dwAttributes != INVALID_FILE_ATTRIBUTES ){<br />
if( dwAttributes & FILE_ATTRIBUTE_DIRECTORY ){<br />
bDirectory = TRUE;<br />
}<br />
}<br />
<br />
return bDirectory;<br />
}
|
|
|
|
|
Ann66 wrote:
I want to check whether the string is a valid path. Is there any function to check that..
Yes, PathFileExists defined in Shlwapi.h
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi,
Please help me!
My situation is:
I want to write a program which converts Microsoft file (*.doc, *.xls ...) to RepliGo file (*.rgo) for viewing them on Palm.
RepliGo support virtual printer, so I think we can print our documents to that virtual printer, then RepliGo will
convert them to *.rgo.
But my current problem is:
After RepliGo receive your file to print (or convert to .rgo), it shows a Dialog which ask you to name the output file.
I want my program convert a set of files continously, so this Dialog is really a fence to do that purpose.
I don't want to let User see that Dialog.
Please tell me how to prevent that dialog showing and simulate clicking event to OK button on that Dialog to name output file automatically.
Thank a ton.
|
|
|
|
|
You'll need to look into hooking - specifically the hooking of the creation of windows. You should be able to google and fnid plenty on the topic and maybe even some articles on this site.
|
|
|
|
|
Hey,
can anyone help me with this problem:
I've an application with a CTreeCtrl. No I want to chatch the rigth-mousebutton in order to display a contextmenu (depending on selected treeitem).
So I created the follwing eventhandler:
<br />
void CFormTestTree::OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult)<br />
<br />
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);<br />
HTREEITEM hItem = pNMTreeView->itemNew.hItem;<br />
CObject *pObject = (CObject*) m_tcTree.GetItemData(hItem);<br />
The error occours in the last row.
The same code works in the eventhandler-function for the SelChange without any problems.
WHY?
Thanx a lot....
P.S. I forgott to say that the problem is the same when I use the GetMousePos() and HitTest() function to get the Item!
|
|
|
|
|
Hey, I solved the problem with HitTest(). I 've forgotten to convert the point with the ScreenToClient() function. But I have not solved the problem with OnNMRclickTree1 yet...
|
|
|
|
|
Remember, this handler is call whenever the user right-clicks on the tree control. The area clicked on may not be associated with an item, so you need to handle that case.
Software Zen: delete this;
|
|
|
|
|
I am writing a MFC application in VC++. The application needs to be able to open the CD-ROM drive. I am currently using the mciSendString function but i can not get the project configured properly.
i have included windows.h
I played around with linking the winmm.lib library into the project but with no success.
my code:
#include <windows.h>
.
.
.
mciSendString("open cdaudio wait", NULL, 0, NULL);
mciSendString("set cdaudio door open", NULL, 0, NULL);
Can anyone give me an explanation of what i need to include to get mciSendString to work or another way to open the CD-ROM? I've found MSDOS executables that can open the CD_ROM drive but i can not find code on how to do this.
|
|
|
|
|
jet915 wrote:
The application needs to be able to open the CD-ROM drive.
Try:
MCI_OPEN_PARMS mciOpenParms;
MCI_SET_PARMS mciSetParms;
DWORD dwResult;
mciOpenParms.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
dwResult = mciSendCommand(NULL, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID, (DWORD) ((LPMCI_OPEN_PARMS) &mciOpenParms));
if (0 == dwResult)
{
dwResult = mciSendCommand(mciOpenParms.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD) ((LPMCI_SET_PARMS) &mciSetParms));
...
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello can anyone tell me how to access shared folders on Lan for copying something in them.
Be FaithFull To Your Work.
|
|
|
|
|
Use the \\server\share convention, also known as UNC.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Which class of VC6 is used for the above job , i mean getting the list of shared folders on LAN and then copying something(Daily schedule for every employee) in it.I want to do this job programmatically.
Please Help.
Be FaithFull To Your Work.
|
|
|
|
|
Usman Tasleem Akshaf wrote:
Which class of VC6 is used for the above job
Any function or method that can handle UNC will work.
Usman Tasleem Akshaf wrote:
i mean getting the list of shared folders on LAN...
Use the WNetOpenEnum() and WNetEnumResource() pair.
Usman Tasleem Akshaf wrote:
...and then copying something(Daily schedule for every employee) in it.
Use CopyFile() or SHFileOperation() .
Usman Tasleem Akshaf wrote:
Be FaithFull To Your Work.
BTW, there's only one 'l' in faithful, assuming it's not meant to be misspelled.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
do we need the ip adress or need to connect to the particualar computer and then access the shares folder or only use the above functions
ddd
|
|
|
|
|
Have you read the documentation and the examples for the functions I mentioned?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Well, this is probably one of the biggest newbie question around here, but I'm having problems with assigning my Label text to a variable (ex a string).
My problem explained with code looks like this:
Label *myLbl;
string myString = "Hello there";
myLbl = new Label;
myLbl->Text = myString; //error C2664 Cannot convert from string to System::String __gc *
This does obviously not work, and I have searched for quite some time now after just a simple sollution to this simple problem, no result finding something. So I hoped someone here could help me out with this one.
Best Regards,
Hmmkk
|
|
|
|
|
The Managed C++ forum might offer better help.
Just my guess, maybe you need to use the c_str() method?
myLbl->Text = new System::String(myString.c_str());
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Well yes, I was afraid that this belonged there but I was not totally sure.
Thanks though.
But well it didnt quite solve my problem, now I get the error;
Just-In-Time Debugging
System.NullReferenceException
To make the code a little more clear, if now it matter I don't know.
This is how I want it.
lblQ->Text = myQuestions[CurrentQuestion]->getQuestion()
myQuestion is a pointer class and getQuestion returns the variable theQuestion which is defined as a string.
and also I just tried two ways:
1:
lblQ->Text = new System::String(myQuestions[CurrentQuestion]->getQuestion();.c_str());
2:
myQuestions[CurrentQuestion]->setQuestion("hi");
string temp = myQuestions[CurrentQuestion]->getQuestion();
lblQ->Text = new System::String(temp.c_str());
Both gave the Just-In-Time debugger error.
Best Regards,
Hmmkk
|
|
|
|
|
Howdy-
I am looking for some clues.
I need to make a window that will track another application, and "dock" itself to the side of that other application.
I am looking for the and easy and efficient way to watch the position of another window and buddy my window up to it. All clues welcome!
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I am writing a add-in for some other program (can't say which) -- and though this program offers a plug-in interface, they offer no UI support.
For the sake of a demo, we want to put a button on their window. I plan to do this by tracking their app (size, location, focus) and positioning myself next to them... like a little puppy dog chasing his master -- my button/window will track this other application.
My assumption is that I mush hook their application with something like SetWindowsHooEx() and get the important messages and post them back to my app which will reposition itself to match that app.
I guess the question is -- is there any other way to do this, than to create a DLL, inject it into their process space, and post messages back and forth?
Thanks
-p
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Peter Weyzen wrote:
is there any other way to do this, than to create a DLL, inject it into their process space, and post messages back and forth?
Nope, Unless that APPLICATION expose Interface to do so!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I don't use bit fields much at all. I have a simple struct as folows (on an INTEL format machine):
typedef struct{
short f1 : 13;
short f2 : 1;
short f3 : 1;
short f4 : 1;
} tststruct;
tststruct tst;
tst.f1 = 8000;
what ends up happening is f1 gets a value of 0xFF40 instead of what I thought I would get (0x1F40). The other members (f2,f3,f4) are all 0x00 as I would expect.
Any idea why?
|
|
|
|
|
Maybe the compiler fills up the remaining 3 bits with ones instead of zeros? Maybe you can do an & with 0x1FFF to filter out the first 3 bits.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|