|
Hi
I have a CStringArray containing a list of a few files from directory. Now I want to search the array for a specific file, thats the way I do:
for(int i=0; i<arMaps.GetSize(); i++)
{
if(!stricmp(arMaps.GetAt(i), "test.txt"))
return;
}
But the file is not found, why? It definately exists.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
How did you obtain the information that is stored in the array? Could the strings in the array be the full path, not just the filename and extension?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
No, it is only the filename without any path in the array. I have checked it in the debugger as well :/
modified 12-Sep-18 21:01pm.
|
|
|
|
|
A quick peek at the help tells us that GetAt(int) returns a char. Pretty good chance it does not return a pointer to a string of characters.
If instead of using the runtime function of stricmp(), you had tried to use the CompareNoCase() method of the CString class, you likely would have avoided this error.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
No, I found the problem: The files in the array have no extension, dunno why I have overseen this :/
Now it works with stricmp as well.
thanks anyway both of you for the help
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have a menu item called " THis is the same as pressing Button A" . So I want it to run button A's OnButtonA() when its pressed.
COnversely, if I have a button B and want to trigger the OnMenuItemX() handler which just has a messagebox in it, how do I do this?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Just give the menu item and the button the same ID.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Just add a function that does the work, say do_that_thing_you_do , and call it from inside both the handlers.
OnButtonA () {
do_that_thing_you_do ();
}
OnMenuItemX () {
do_that_thing_you_do ();
}
do_that_thing_you_do () {
}
cheers,
-B
|
|
|
|
|
I get it! Many thanks!
Appreciate your help,
ns
|
|
|
|
|
SO I have a menu item that when clicked, runs a function OnMenuA(). WHen I click another menu item, I want to run the function that was triggered by pressing on the first menu item
Appreciate your help,
ns
|
|
|
|
|
You just do the same thing you did for the first menu.
ON_COMMAND( FIRST_MENU_ITEM, OnMenuA )
ON_COMMAND( OTHER_MENU_ITEM, OnMenuA )
Or did I miss something obvious ?
Max.
|
|
|
|
|
Well,
I wasnt the one that put in the ON_COMMAND stuff.......it gets put in automatically. SO when I use the CW and tell it to put in a COMMAND handler for a particular menu ID ID_B, it suggests a name OnMenuB for the handler . I guess you are saying that dont accept this default name but change it to OnMenuA.
Thank you much! It never crossed my mind.....
Appreciate your help,
ns
|
|
|
|
|
I create a SDI projekt with the wizard. Then I put a Dialog in the View (FormView)!. And in this Dialog in a spezific Rect I want to Create a modeless Dialog (not doModal)!. So I can see the Dialog but I cant work on it pressing buttons and so on. How can I fix this problem?
The source from the Dll:
//////////////////////////////////////////////////////////////////////////////
CDlgTest dlg;
extern "C" __declspec(dllexport)
void InitTest(BOOL Test, CRect rect)
{
DWORD dwLastErr = NO_ERROR;
// surround the code in brackets, which will cause the temporary
// object created by AFX_MANAGE_STATE to be destroyed before leaving
// the exported function.
//
// NOTE : Do NOT call MFC code outside of these brackets.
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
dlg.Create(IDD_TEST, AfxGetMainWnd());
dlg.MoveWindow(rect);
dlg.ShowWindow(SW_SHOW);
//
// save possible errors
//
dwLastErr = ::GetLastError();
}
// only set error if none is currently set.
// (last error will always be NO_ERROR _unless_
// TlsGetValue failed earlier)
//
if (::GetLastError() == NO_ERROR)
::SetLastError(dwLastErr);
}
//////////////////////////////////////////////////////////////////////////////
Can anyone help me?
mail: dawo.office@gmx.net
Thanks.
|
|
|
|
|
I have a problem accessing (writing and reading) the DS register.
If I include this sequence in my MFC-C++ program the app crashes:
mov ds, dx
I replaced it by the following code, but the app also crashes:
push dx
pop ds
It seems that it is forbidden to access the DS register in a MFC-C++ program?
But in assembler this is allowed and works fine!
Please help... how can I make the code above working??? Any pragmas or such things?
-Dominik
|
|
|
|
|
Just taking a guess here...
On a 32-bit system DX is EDX. EDX is a 32-bit register and DS is a 16-bit register. You can't move 32-bits of data into 16-bits without something going wrong.
You said it worked in "assembler" before? Was that on a 16-bit system or an emulated 16-bit system (a.k.a.; WOW)?
Just my thoughts on the matter...
Jeremy Falcon
Imputek
<nobr>Excrement escapes everyone - even elders.
|
|
|
|
|
|
I don't recall seeing DS being used very much in the assembly listings I have stared at.
However, anytime you modify a register make sure that you have pushed it before hand and popped it afterwords. These (push and pops) usually happen at function entry and exit, depending on the calling type (_cdecl or _stdcall.)
This is standard ASM etiquette.
The Ten Commandments For C Programmers
|
|
|
|
|
I DO push and pop the registers...
See MSDN page "Interrupt 21h Function 71AAh Minor Code 0h", then you know what I want to do...
But if accessing the DS register is impossible... how do we then create drive substitutions in Win32 ???
Thanks for your reply
-Dominik
|
|
|
|
|
Unless I'm completely fragged, this is not something you want to do.
Visual C++ creates Win32 applications. Win32 applications run in protected mode. In protected mode all the segment registers point to the same descriptor that's internal to the OS. You don't want to touch them, because something somewhere will think you're trying to access memory that doesn't belong to your process, and crash.
You're caught up in 16-bit mode. Wake up and smell the late 80s.
Or start looking at 32-bit assembly to write your viruses... Let me know if you need some pointers.
J
May the bear never have cause to eat you.
|
|
|
|
|
I wanted to use the INT 0x21 routine (sub 0x71AA) to associate a drive letter to a path.
See MSDN "Interrupt 21h Function 71AAh Minor Code 0h".
No way to do this any more???
Thanks for your reply
-Dominik
|
|
|
|
|
Dominik Reichl wrote:
No way to do this any more???
Not like that. That's DOS. Depending on your target platform, you'll probably have to go through the API. And I couldn't tell you where to begin looking for the solution in MSDN.
You could, however, start here[^].
J
May the bear never have cause to eat you.
|
|
|
|
|
Of course you could just do this:
system("subst q: \myfiles");
J
May the bear never have cause to eat you.
|
|
|
|
|
Hello, everyone.
Precursor:
I've developed in Visual C++ 6.0 for a while and now I'm developing in Embedded Visual C++ 3.0 for handheld devices. One of the pecular behavioural patterns, or rather, differences, between 6 and 3 is the auto-inclusion of MESSAGE_MAPping through to a control placed on a dialog. This also leads to the inability of 3.0 to allow member variables to be generated through the Class Wizard.
Which leads me to my question:
A) Where can I learn (through an on-line tutorial) about how the MESSAGE_MAPping works so I can enable dialog controls on my dialog without manually '#define'ing every dialog control by hand? (Or, at least, if I must do it by hand, what is the best method to perform such tasks.)
I'm also adding, as a member variable, a CListBox object and calling m_myListBox.Create(...rect,IDC_MYLISTBOX) to actually have a list box on the dialog. The intesting thing is this: 'IDC_MYLISTBOX,' on the dialog, in not visible. I only need the IDC_MYLISTBOX value for my create routine and after Create returns, I have a listbox. (Values added later through code.) If I delete the control from the dialog, the program bombs because EVC++ 3.0 needs its reference number from the resource file.
I'd, truely, rather not include a list box control on the form and then hide it and *then* call create on a member variable of type CListBox. Does that make sense to you?
B) Should/Can I write in my own function maps through the MESSAGE_MAP routines of my classes when such class behaviour should be associated with a dialog control?
C) Are there any sites primarily associated toward developing hand held devices?
I hope my questions make sense. I know that in 6.0 it is bad Ju-Ju to toy-around in the MESSAGE_MAPs.
I've a dozen more questions with this topic/EVC++ 3.0 but I'll hold them for the moment. Thanks!
|
|
|
|
|
y ! FAQ's?
~CodeTheDreams~
|
|
|
|
|
Thanks for the reply but it is a little vague.
Are you talking about the Mike Dunn's C++ FAQs on this website? If not, where?
|
|
|
|