|
I am running a multiproject application and in one of the projects, there is a Process created using CreateProcess. This process uses an executable created in another project of this same application to perform certain tasks.
I am under the impression that if I add "DEBUG_PROCESS" as one of the options under CreateProcess, I should be able to debug into the Process (i.e. Go F11 and right into the actual file).
However, what I seem to get is a program that sort of hangs when it gets to WaitForSingleObject statement.
Any ideas of how to debug into a Process? What am I doing wrong?
thanks
|
|
|
|
|
Hello, the codegurus around the world.;)
I have the same problem to debug some project.
In this case, I wrote the following.
#ifndef _DEBUG
WaitForSingleObject (...);
#endif
This approach will not solve the basic problem, but
we can debug the different EXE created by CreateProcess.
So, in the debug mode, we can teminate the main exe process by debug menu,
otherwise, we will get some messy situation since we never call WaitForSingleObject.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I am using MFC for a XP program, and have various controls on the dialog box.
When I add my .manifest file, all the controls are displayed as they should be (flat, hot tracking etc), but if I add the style "ES_PASSWORD" to an Edit box, I don't get the '*' character or the XP black circle, instead I get a small black rectangle.
Help.
Joe.
|
|
|
|
|
Hello, the codegurus around the world.;)
I think that this is normal since MFST seems to change the password
word from * to the black circle on XP.
Windows application depends on the core DLL of Windows, so
as long as we use DLL of XP, I think that we can't change this.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
A while back I posted this question here but no one replied. Let me try again...
I have a console app which prompts the user for a user id and password. The problem is that I don't know how to prevent the password from being displayed as the user types it. I'm using good old cin to retrieve it, like this:
cout << "Password: ";
char szPassword[80];
cin.getline(szPassword, sizeof(szPassword));
Is there a way to hide what the user types or perhaps mask it somehow?
Thanks,
Alvaro
|
|
|
|
|
char c = 0;
while (c!=' ')
{
if(kbhit())
{
c=getch();
printf("*");
}
}
-c
POKE 808,234
|
|
|
|
|
Thanks for the quick answer Chris. Now, to throw a monkey wrench into the solution: it has to compile and run on both Windows and UNIX. Is there an equivalent to kbhit on UNIX?
Thanks again,
Alvaro
|
|
|
|
|
Alvaro
In windows you can do this :-
while((c=_getch())!='\n')
{
printf("*");
s[i++]=c;
}
s[i]='\0';
For Linux/Unix you'll need to write your own _getch() function.
You can do this with not too much difficulty
(1)First open /dev/tty
(2)use ioctl to change keyboard device parameters [there is some flag to prevent echoing]
(3)Then read one character
(4)use ioctl to set echo back
(5)Now close /dev/tty
I am sorry I couldnt actually put the code here, but if you have access to a unix box you can lookup ioctl and /dev/tty in the man pages and figure out a way.
Regards
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
Unix/Linux does haven't a getch()!
I'd have thought with all those open source programmers they could get round to doing one of the most basic input functions. I'd have though getch() would have been part of the standard c library.
Michael
|
|
|
|
|
Thats cause in Linux they dont take passwords from the keyboard. They put it in a file and put the file in /etc and chown it to root and chmod it to 000
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
Nish,
Thanks for your reply. I got it working on Windows, which by the way requires me to look for '\r' instead of '\n'. Now I'm trying UNIX but I'm lost:
(1)First open /dev/tty how? with fopen?
(2)use ioctl to change keyboard device parameters [there is some flag to prevent echoing] could not find such flag.
(3)Then read one character how? with fgetc?
(4)use ioctl to set echo back again, I don't know how
(5)Now close /dev/tty I imagine with fclose, but then what, repeat for the next character?
Thanks for your help,
Alvaro
|
|
|
|
|
Well, I got it working so that it doesn't show any characters. It's not as pretty as the masked solution, but it's easier and it works. Here's the code for the method, in case someone's interested:
string getPrompt(const char* szPrompt, bool bShow = true)
{
cout << szPrompt << ": ";
char szResponse[80];
if (bShow)
cin.getline(szResponse, sizeof(szResponse));
else
{
#ifdef _WIN32
int iPos = 0;
for (int c = 0; (c = getch()) != '\r'; )
{
if (c == '\b')
{
if (iPos > 0)
iPos--;
}
else if (isprint(c) && iPos < sizeof(szResponse) - 1)
szResponse[iPos++] = c;
}
szResponse[iPos] = 0;
#else
system("stty -echo");
cin.getline(szResponse, sizeof(szResponse));
system("stty echo");
#endif
}
return szResponse;
}
Thanks for your assistance.
Alvaro
|
|
|
|
|
Not within iostream , I think. You'll have to capture keystrokes with _getch() and print out the asterisks yourself (handling backspaces is a little tricky, also).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How do i use loops in MFC?
Whenever i use a for loop my MFC program freezes!
thanks
|
|
|
|
|
Could you post your code?
"But, daddy, that was back in the hippie ages..." My twelve year old son - winning the argument.
"Stan, you are an intelligent guy who responds in meaningful ways" Paul Watson 16/10/01
|
|
|
|
|
heres the code
do
{
if ((x % counter == 0) && (y % counter == 0))
{
x = x / counter;
y = y / counter;
}
counter -= 1;
}
while (counter > 0);
|
|
|
|
|
wait.
i figured it out
it was because i was using INT_MAX
how do i use INT_MAX in MFC without crashing or is there an other way?
|
|
|
|
|
What do you mean it's because of INT_MAX. Do you mean you're looping INT_MAX times??? That would explain it!
If you don't give your window the ability to process messages (such as mouse clicks) while the loop is running, it will freeze. Write yourself a little function like this:
void AMS_ProcessMessages()
{
for (MSG msg; ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); )
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
And call it inside your loop. That should, if nothing else, prevent your window from freezing.
Regards,
Alvaro
|
|
|
|
|
i used INT_MAX for my intial counter value.
int counter = INT_MAX;
and then decreasing the coutner by 1 each time the loop processes
|
|
|
|
|
You do realize that the loop is going to execute 2,415,919,103 times, right?
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Alright, I'm new at programming in Windows API...My current two problems are the following. Any solution would be appreciated.
1: I have a text box in my program. In past programs such as DOS console-based programs, I could skip lines with the character '\n'. I tried it with this, it just displays a null character. How do I skip lines in a text box?
2: How do I make the background on a button a different color? I've gotten some advice to this but it wasn't very specific enough, this seems to be more complicated then it should be. Bill Gates is an ass. So how would I make the background on a button with handle, say, cmdStart, be, say, green?
Thanks for any help =)
Dave
|
|
|
|
|
1. What do you mean by "text box"? If it is an edit control, then make sure you have the "multiline" checkbox marked for the control (go to the resource editor, right click on the control and select "Properties"). If this is not what you're referring to please elaborate.
2. You're right changing the background of a color is unjustifiably hard. An excellent way to do it is explained in Yuri Goltsman's article Colored/Blinking Controls and Dialogs with any Font.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How do I skip lines in a text box
\r\n
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Bill Gates is an ass.
LOL, that's great!
That's why he invented VB, to cover his "assness" up a bit. I'm sure you know that changing a button's background in VB is a piece of cake. In MFC it's a mission. And it's not because of C++, it's because MFC is mostly a thin wrapper around the Win32 API.
I hope Joaquin has pointed you to the solution, but if not, take a look at the CWnd::OnCtlColor in MSDN. I believe that's the easiest way to make it work without having to derive your own button class.
Regards,
Alvaro
|
|
|
|
|
If I am making a dialog box application with multiple dialog boxes which are supposed to appear in a given sequence then do I create them all at the same time, and keep all but one hidden?
Or do I create the next dialog box to be shown inside the current dialog box?
In the former case, the current dialog box will call the next dialog box's display function..
And in the latter case, an new dialog box is created (say while closing the current dialog box)
Which approach do you think is better?
|
|
|
|