|
<br />
string fixedPath = @"c:\program files\";<br />
FileInfo fileObject = new FileInfo(fixedPath);<br />
fixedPath = fileObject.FullName;<br />
MessageBox.Show(fixedPath);<br />
This would return "c:\program files".
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
Ok, I've got everything working.
It seems GetDirectories is actually fast enough when using a search pattern.
Thanks for reading through the code, and here's what I'm using now.
<br />
public List<string> Generate(string generationString) {<br />
List<string> results = new List<string>();<br />
<br />
string[] pathParts = generationString.Split(Path.DirectorySeparatorChar);<br />
DirectoryInfo currentDirectory = null;<br />
<br />
for (int index = 0; index < pathParts.Length;index++ ) {<br />
string pathPart = pathParts[index];<br />
<br />
if (index == 0) {<br />
DriveInfo[] drives = DriveInfo.GetDrives();<br />
foreach (DriveInfo drive in drives) {<br />
if (drive.Name.StartsWith(pathPart, StringComparison.InvariantCultureIgnoreCase)) {<br />
currentDirectory = drive.RootDirectory;<br />
}<br />
}<br />
if (currentDirectory == null) {<br />
break;<br />
}<br />
} else if ((index == pathParts.Length - 1) ) {<br />
try {<br />
results.AddRange(Directory.GetDirectories(currentDirectory.FullName, pathPart + "*"));<br />
results.AddRange(Directory.GetFiles(currentDirectory.FullName, pathPart + "*"));<br />
} catch { }<br />
} else {<br />
DirectoryInfo[] searchResults = currentDirectory.GetDirectories(pathPart);<br />
if (searchResults.Length == 0) {<br />
break;<br />
} else {<br />
currentDirectory = searchResults[0];<br />
}<br />
}<br />
}<br />
<br />
return results;<br />
}<br />
</string></string></string>
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
I have the following event handlers for a button and a text box:
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e)
{ function(0);
}
private: System::Void textBox_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e)
{ if(!CheckIfTextBoxNumeric(textBox))
e->Cancel = true;
}
bool CheckIfTextBoxNumeric(TextBox^ myTextBox1)
{ //checks text input only contains numbers
//returns true if so
}
void function(int select)
{ int result = 0;
//validate text is digit
try
{ result = Convert::ToInt32(insrtMnytxtBox->Text); -- line A
}
catch(Exception^ myException)
{ cstmrInfolabel->Text = "Exception : ",myException->Message;
}
//rest of code
}
When program execution reaches line A in function, program does not pause for text input from user, that is, program does not allow user the chance to enter numbers. In C++ it would be the equivalent of cin >> result; How can I cause the program to pause so that the user has a chance to enter something.
|
|
|
|
|
This question belongs in the Visual C++/CLI forum.
I'm guessing you haven't written code for Windows before, have you? What you mentioned with the cin stream applies to console applications, not Windows.
Windows is follows an event driven model where your code normallly sits idle, waiting for the user to click on things and type. You caannot do what you want, the way you want. The best method for filtering out keystrokes is to create a custom TextBox control that does just that. Another method would be to handle the TextBox's Keydown event and do your filtering in that handler.
|
|
|
|
|
If I use the SetWindowLong in VB, I get the positive return value. Now we are migrating to vb.net and if I tried using SetWindowLong in vb.net, I get negative value. The third parameter in SetWindowLong is dwNewLong, am using delegate here to point to the address of the function I wanted to point to. (for example - AddressOf MyFunction)
I tried using different function definition but no success.
I used following -
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, _
ByVal nIndex As Integer, _
ByVal dwNewLong As MyFunction) As Integer
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As IntPtr, _
ByVal nIndex As Integer, _
ByVal dwNewLong As MyFunction) As Integer
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Int64, _
ByVal nIndex As Int64, _
ByVal dwNewLong As MyFunction) As Int64
Can anyone help me with this?
|
|
|
|
|
This should have been asked in the VB/VB.NET Forum.
Read the Community Content Section at the bottom of this page[^] for information on how to do this.
|
|
|
|
|
Thanks for that. I tried using those function but getting two errors -
Messages.WndProc - Type is not defined
Messages.WindowMessages - Type is not defined
|
|
|
|
|
You have to define those enums yourself. They just represent the message numbers found in the Windows header (*.h) files. You can find an example of some of the window message numbers here[^]. Messages.WndProc is the delegate that's listed in the code.
|
|
|
|
|
Am sorry to trouble you again. I'm confused. I might not getting what you are saying. I am not a much experienced developer. I'm using VB.Net with .Net Framework 1.1. Please see below what have tried -
Public Enum WindowMessage As Integer
WM_ACTIVATE = 6 ' can't use Hex value WM_ACTIVATE = 0x0006 giving error 'End of statement expected so converted that hex value to decimal as 6.
End Enum
Public Delegate Function WndProc(ByVal hWnd As Integer, ByVal msg As Messages.WindowMessages, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Error - Messages.WindowMessages - Type is not defined
Friend Declare Auto Function SetWindowLong Lib "user32.dll" (ByVal hwnd As Int32, ByVal nIndex As WindowProcs, ByVal NewProc As Messages.WndProc) As Boolean
Error - Messages.WndProc - Type is not defined
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, _
ByVal nIndex As Integer, _
ByVal dwNewLong As MyFunctionDelegate) As Integer
My hook function looks like this -
Public Sub Hook()
Try
Dim intError As Integer = GetLastError
MsgBox(intError)
SetLastError(1)
Dim intError1 As Integer = GetLastError
lpPrevWndProc = SetWindowLong(ghW, GWL_WNDPROC, AddressOf MyFunction)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Note - Getting Last Error as 126 which means 'Module not found.'
MyFunction Delegate is like this -
Public Delegate Function MyFunctionDelegate(ByVal hw As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
MyFunction looks like this -
Public Function MyFunction(ByVal hw As Integer, _
ByVal uMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
Select Case uMsg.ToString
Case ABC
do this
Case DEF
do this
Case Else
MyFunction= CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Select
End Function
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Integer, _
ByVal hWnd As Integer, _
ByVal Msg As Integer, _
ByVal wParm As Integer, _
ByVal lParam As Integer) As Integer
|
|
|
|
|
bhawaniprasad wrote: Public Enum WindowMessage As Integer
WM_ACTIVATE = 6 ' can't use Hex value WM_ACTIVATE = 0x0006 giving error 'End of statement expected so converted that hex value to decimal as 6.
End Enum
This is because you have to use VB's syntax to specify a Hex value:
WM_ACTIVATE = &H6
bhawaniprasad wrote: I am not a much experienced developer.
You've taken on something that is a very advanced technique for a beginner.
bhawaniprasad wrote: Messages.WindowMessages - Type is not defined
This means that YOU have to define the enumeration called WindowMessages. You can drop the Messages. part. The values come from the Windows.h C++ header files that describe each window message.
bhawaniprasad wrote: Messages.WndProc - Type is not defined
Again, drop the Messages. part. You have to leave the WndProc part.
|
|
|
|
|
what event happens immediately fater user changes the collection selection.
I want to get access to the selected item collection before it is actually changed so I can either rollback or acces the previous selected collection indexes.
thanks
Shimi
|
|
|
|
|
meanwhile I am using CellMouseEnter
this does the work though it reduces performance
Shimi
|
|
|
|
|
|
|
He actually put it in three forums and then deleted them all. Pathetic.
|
|
|
|
|
leckey wrote: He actually put it in three forums and then deleted them all. Pathetic.
Another entry for the blog of shame.
|
|
|
|
|
if u guys are not interested to help.. jus ass lock and ignore..
you cannot comment on others..
Message boards are intended to discuss.. Not Chat or Comment or stuff..
There are 5,108,764 in the site.. Why it aches on your ass wn others ignores them...
"People gives advice wen there is a need of help..
And wen there s a need of an advice...They do the same"...
Useless creatures..
|
|
|
|
|
Well, thank you for that incoherent babble. It's always a pleasure to insert the missing characters in a sentence.
shabbu wrote: you cannot comment on others..
To quote Dr Cox from Scrubs:
"Wrong wrong wrong wrong, wrong wrong wrong wrong. Wrong"
|
|
|
|
|
shabbu wrote: Message boards are intended to discuss.
But this guy decided to spam the site with the same question multiple times. This isn't discussing - IT'S SPAMMING!
shabbu wrote: Not Chat or Comment or stuff..
So someone posts a response to a question and the rest of us are not allowed to comment on it?? What definition of "discussion" are you using??
|
|
|
|
|
We are not interested in helping people who flagrantly break the rules.
As for you, please learn English.
shabbu wrote: Useless creatures..
Don't let the door hit you on the way out.
|
|
|
|
|
We've got a live one chipping in on this conversation.
|
|
|
|
|
Obviously someone started a new ID to start a flame war. I hate these little buggers who try to insult us and do it with English so bad I just start laughing. Seriously, who would come up with "jus ass lock and ignore?"
|
|
|
|
|
leckey wrote: Seriously, who would come up with "jus ass lock and ignore?"
Sounds like advertising for one of those diarrhea adds.
|
|
|
|
|
Hey come on guys. I was in need of that program. Had lesser time to do. so I thought someone would help if they have such similar codings. When I was told that it was a mistake, I accepted it and deleted the message. But I never thought it would end like this. I apologize for the mistake(for cross posting). I have prepared the program and the issue is over. So ignore it.
modified on Thursday, May 8, 2008 2:08 PM
|
|
|
|
|
You should have deleted 2, and left 1.
|
|
|
|