|
msdn says this about SetProcessShutdownParameters()...
"This function sets a shutdown order for a process relative to the other processes in the system."
Its does not say that it allows a process to terminate the shut down process.
I think this fucntion AbortSystemShutdown() is what you are looking for but Im not sure
|
|
|
|
|
WM_QUERYENDSESSION
The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls the ExitWindows function. If any application returns zero, the session is not ended. ////The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero.
/////
After processing this message, the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message.
A window receives this message through its WindowProc function.
WM_QUERYENDSESSION is sent to program from the high Shutdown priority to low
|
|
|
|
|
Hi everyone, i am getting angry while trying to insert richedit control, to my small dialogbox application.
Well, everything works fine to the moment i put the richedit control on my dialogbox, then
application starts and exits in some of 1ms.
My program is basically a dialogbox application, i wanted to implement a nicee richedit control but when i only put her inside the dialogbox, the app does not work!
Any ideas?
ps1. hwnd= DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc);
that's how i init my main program dialog box
ps2. all other controls beside richedit - work fine, i'm having a big problem.
|
|
|
|
|
If you are using a rich edit control in a dialog box (regardless whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program’s InitInstance member function. You do not need to call it for each time you display the dialog box, only the first time.
e.g.
BOOL CMyApp::InitInstance()
{
AfxEnableControlContainer();
AfxInitRichEdit();
………………………….
}
Naveed Shoaib
|
|
|
|
|
Hello,
what 'bout not MFC app ? I'm writing in pure w32 API, is there any
chancee to run that?
|
|
|
|
|
I need to write a program in visual C++ 6.0 that will read and HTML file and modify contents programmatically. Especially I need to cause the pushbuttons within the HTML file to execute. Can anyone help me with this.
Freeman Taylor
|
|
|
|
|
Reading and modifying HTML is easy if it's XHTML, just read it into an XML document. How do you mean you want the buttons to execute ? You actually want not just to read them, but to run them in a browser programatically ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
Yes, guess I wasn't too clear. I have to program a "wrapper" around some existing HTML code. Within the HTML code I want to choose certain selections in the HTML and cause them to execute but keep the HTML code from being visible, so I guess that would be as you say to run them in the browser programatically. I have been reading up on the IDispatch methods from Microsofts web site, but can't seem to make it work.
Thanks for your help
Freeman Taylor
Freeman Taylor
|
|
|
|
|
My aim is to control the backColor of the CStatic that I use in my app. So I derived a class from CStatic . Now The text that gets displayed needs to be according to a Custom font. I am handling the
BOOL CHeadingStatic::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) <br />
{<br />
if (message != WM_CTLCOLORSTATIC)<br />
{<br />
return CStatic::OnChildNotify(message,wParam,lParam,pLResult);<br />
}<br />
HDC hdcChild = (HDC)wParam; <br />
if(colored)<br />
SetBkColor(hdcChild,RGB(0,120,120));<br />
*pLResult = (LRESULT)(m_brush.GetSafeHandle());<br />
return TRUE;<br />
}
Now I added another public
<br />
void CHeadingStatic::ChangeFont()<br />
{<br />
SetFont(&headingFont);<br />
<br />
} method in this class to change the Font .
So externally I first creating this object and then
doing an
<br />
object.create(......)<br />
object.ChangeFont()
I notice a lot of flickering and it takes a while to come up . Is there a way i can do this during creation ?
Engineering is the effort !
|
|
|
|
|
I'm trying to define a class for vmr9 rendering. Conform to the DX9DSK docs i use the CLSID_VideoMixingRenderer9, but it says is not declared:
"e:\Programming\VC++\VMR9WindowlessRender.cpp(632): error C2065: 'CLSID_VideoMixingRenderer9' : undeclared identifier"
Any ideeas ?
|
|
|
|
|
I have:
(nh-nl + 1) 1247923961
and calloc fails:
v=(double *)calloc((nh-nl+1),sizeof(double));
v is zero.
How do I fix this? Why is this happening?
|
|
|
|
|
I think you are trying to allocate over 2GB of space.
|
|
|
|
|
You're allocating over 8GB of memory. Windows won't let you do this...
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"
|
|
|
|
|
Thanks for the responses. I was really puzzled about that. I wonder what makes calloc fail other than insufficient memory.
Thanks,
sb
|
|
|
|
|
Is there source code that will load a BMP or a JPG file and present that as if it is coming from a web camera so that MSN or Yahoo web cam will believe that it is using a valid web cam? There is a commercial software called VirtulaCamera but I am lookin for source code. Any help is appreciated. Thanks
Watchman
|
|
|
|
|
Looking for anyone with experience developing a decoupled WMI provider - without .net class nor ATL. SDK examples just don't do it, and microsoft forum is no help either.
Hint: It would be a GREAT article for codeproject posting!
tim
|
|
|
|
|
Like in topic.. this question may be silly, but I'm new programmer so be gentle (plz). What should I do if I want to "refresh" the value of variables in DOS version? I'll include here a part of my source code. Treat this as a sample of my problem.
for( ;; )
{
int result = GetKeyState(VK_SHIFT);
if(retult == 1)
{
..code..
}
}</code>
This code will slow down every comp - I think. I need a solution of that problem. Thanks in advance.
_________<br />
I'm made in C++... and I'm proud of it!
|
|
|
|
|
SetTimer(NULL,NULL,1,NULL);
case WM_TIMER:
int result = GetKeyState(VK_SHIFT);
if(retult == 1)
{
..code..
}
break;
or
you can use your code but put this extra
for( ;; )
{
int result = GetKeyState(VK_SHIFT);
if(retult == 1)
{
..code..
}
Sleep(1);
}
gabby
|
|
|
|
|
although for(;;) is valid i suggest you use while(TRUE) instead (the for loop wasnt really intended for infinite loops)
i doubt that it is your infinite loop that is slowing down the computer, try to quiting some process first
i have run many instances of programs that do more than your code seems to be doing, and it didnt affect the speed.
|
|
|
|
|
Before going down this path, see if there is a way to register to recive key pressed events that gives you what you need. What you are doing is called polling, and it ALWAYS slows a computer down. To get around it computers have interupts of various sorts so that you can be told that something happened.
So you have something like:
while(someWaitForKeyEvent()) {
if(GetKeyState(VK_SHIFT) == 1)
..code..
Assuming you have to poll I'd do it something like:
while (1 != (result = GetKeyState(VK_SHIFT)) {
sleep(1); // wait one second before polling again
}
..code..
lookup sleep (including other forms of it like BSleep), see if there is one that will yield the rest of your CPU cycles to other tasks. I suspect sleep(1) is too long so you will want, so find something that does the same thing, but for less time.
Basicly what is happening is you can run GetKeyState several hundred times in your timeslot, but you can call GetKeyState a lot faster than a human could press the keyboard. (look up debouncing sometime, it is taken care of for you, but it will help you see what is going on) So you are looking for a way to tell the computer "I won't be able to do anything for a while, do something else"
One last point: instead of if(result == 1) you should use a constant or an enumeration so you can do if(result == KEY_DOWN) this makes it clearer to readers what you mean. As you wrote you code I'm not sure what it means, while KEY_DOWN tells me something. (There might even be defined constants in a headerfile someplace.
When I first saw your code I was thinking of key as in encryption key, and figured you were waiting on a thread to generate the key! It took me a minute to realise that it was a windows function and then I had to look it up to see what it did)
|
|
|
|
|
I'm having trouble with something that my professor assigned. He's out of town at the moment and hasn't answered any of my emails and the text book doesn't explain how to do this very well. It is an encryption/decryption program. The output should be like this:
Original string is: this is a secret!
Encrypted string is: uijt!jt!b!tfdsfu"
Decrypted string is: this is a secret!
Basically this program turns a character into the next letter of the alphabet. For example t becomes u, h becomes i,spaces become exclamation points, etc. The objective of this lab is to use pointer notation to make the program do this but I don't understand pointers too well. If someone could get me started on this program I'd appreciate it. Here's the template. Where you see /* that's where I have to write lines of code. The part that I'm totally cluless on is the implementation of the functions 'encrypt' and 'decrypt'. Thanks.
#include <iostream>
using std::cout;
using std::endl;
/* Write the prototype for function encrypt */
/* Write the prototype for function decrypt */
int main()
{
// create a string to encrypt
char string[] = "this is a secret!";
cout << "Original string is: " << string << endl;
encrypt( string );
cout << "Encrypted string is: " << string << endl;
decrypt( string );
cout << "Decrypted string is: " << string << endl;
return 0;
} // end main
// encrypt data
void encrypt( char e[] )
{
/* Write implementation for function encrypt */
} // end function encrypt
// decrypt data
void decrypt( char *ePtr )
{
/* Write implementation for function decrypt */
} // end function decrypt
|
|
|
|
|
I have an idea for encrypt implementation only.
Pointers are my bad side. Still working on them.
[btw. You are a lucky guy, coz u have some1 who
can teach you... I'm learning from net and books.]
void encrypt(char array[])
{
char getString[] = decryptedString;
char encryptedString[];
int size = sizeof(getString);
for( int n=0 ; n < size ; n++ )
{
encryptedString[n] = char((reinterpret_cast<int>(decryptedString[n]))-1);
}
}
I'm outta home now.. not sure if it will works.. can't check it now.. I think that code is close to truth though. Hope it works and will help you at least a little.
_________<br />
I'm made in C++... and I'm proud of it!
|
|
|
|
|
IMHO, the common quality to all really good developers is problem solving skills. This quality separates those that do great things in the technology industry and those that are always worried about layoffs.
I see two problems here that you need to solve. The first is the encrypt/decrypt functionality, which the professor has already given the solution. The other problem is how to use pointers.
Is there something more specific you would like to ask?
|
|
|
|
|
<sigh> normally i don't like to answer homework questions, but ...
Without error or roll-over checking the following does what you want.
If you were to hand in as shown i would fail you.
Put in error and roll-over checking and maybe expand to make more readable.
void encrypt( char e[] )
{
for( int i = 0; e[i]; e[i++]++ );
}
void decrypt( char *ePtr )
{
while( *ePtr ) (*(ePtr++))--;
}
...cmk
Save the whales - collect the whole set
|
|
|
|
|
/*
Quaydogg wrote:
Basically this program turns a character into the next letter of the alphabet. For example t becomes u, h becomes i,spaces become exclamation points, etc.
Your synopsis of the problem is close but not 100% correct. As you have stated spaces become exclaimation points. When did spaces become part of the Roman alphabet?
From your very limited example I think what is more likely happening is that you are incrementing and decrementing ASCII character codes. The example string you provided does not have sufficient information to make this statement unequivocally because there is no Z or z in the string but since space (ASCII 0x20)) ==> ! (ASCII 0x21) and ! (ASCII 0x21) ==> " (ASCII 0x22) it looks like that is what is happening.
You should probably verify this with your professor because if you are rotating alphabetic characters than "Z" (ASCII 0x5a)would become "A" (ASCII 0x41) and "z" (ASCII 0x7a)would become "a" (ASCII 0x61) in the encryption routine. If you are incrementing ASCII character codes "Z" (ASCII 0x5a) ==> "[" (ASCII 0x5b)and "z" (ASCII 0x7a) ==> "{" (ASCII 0x7b) and your algorythm is a lot simpler to implement.
I digress, onto the more pressing problem.
Quaydogg wrote:
The objective of this lab is to use pointer notation to make the program do this but I don't understand pointers too well. If someone could get me started on this program I'd appreciate it.
I could give you code that solves the encryption and decryption problem but then you would still not understand pointers which is, in fact, the point (pun intended) of this whole exercise in the first place.
Instead I will provide you with a few illustrations of pointers at work and try to explain what is going on so that, hopefully, you will understand the process more clearly.
To start off pointers, as their name implies, point to something.
This is different than being something as I will attempt to explain.
A pointer is an address of a variable, structure, array, function, etc.
You can reference the thing pointed to by use of the pointer.
The semantics of pointers may be a bit confusing at first but work through it and they will become easier to understand.
In the following examples I will be using cahracter arrays but pointers are by no means limited to strings.
As I said before the pointer is an address of a thing. When you preface the pointer with an asterisk "*" you are working with the actual thing you are pointing to. Individual elements of the character array in the following examples.
Do not confuse this with the asterisk in the type definition of the pointer (i.e. char*, int*, long*, etc.). If you are referencing the pointer you do not use the asterisk, but if you are referencing the thing pointed to you do use the asterisk. A bit confusing at first.
I hope these examples will help you to understand pointers a little better.
*/
#include <stdio.h> // needed for printf
void fn1(char*);
/*
void fn1(char e[]);
This function prototype is perfectly legal also
I just wanted to point out that "char e[]" and "char*"
are the same (a pionter to an array of characters)
*/
void fn2(char e[]);
void fn3(char*);
void fn4(char*);
/* notice how the second parameter passed to function main is "char* argv[]" (pointer to an array of pointers) */
int main(int argc, char* argv[]){
char szString[] = "Hello World!";
fn1(szString);
fn2(szString);
fn3(szString);
fn4(szString);
return 0;
}
void fn1(char e[]){
/* while the thing being referenced (characters in an array) is not null ('\0') */
/* every time the string is printed the pointer is advanced one character position */
while(*e)
printf("fn1 - %s\n", e++);
printf("\n");
}
void fn2(char e[]){
/* the pointer stays the same (pointing to the beginning of the array) */
/* the array index is incremented with every itteration of the loop */
/* eventually the array element equals null ('\0') and the loop terminates */
for(int i = 0; e[i]; i++)
printf("fn2 - %c\n", e[i]);
printf("\n");
}
void fn3(char *ePtr){
/* while the thing being referenced (characters in an array) is not null ('\0') */
/* every time the string is printed the pointer is advanced one character position */
while(*ePtr)
printf("fn3 - %s\n", ePtr++);
printf("\n");
}
void fn4(char *ePtr){
/* the pointer stays the same (pointing to the beginning of the array) */
/* the array index is incremented with every itteration of the loop */
/* eventually the array element equals null ('\0') and the loop terminates */
for(int i = 0; ePtr[i]; i++)
printf("fn4 - %c\n", ePtr[i]);
printf("\n");
}
/*
Program Output:
fn1 - Hello World!
fn1 - ello World!
fn1 - llo World!
fn1 - lo World!
fn1 - o World!
fn1 - World!
fn1 - World!
fn1 - orld!
fn1 - rld!
fn1 - ld!
fn1 - d!
fn1 - !
fn2 - H
fn2 - e
fn2 - l
fn2 - l
fn2 - o
fn2 -
fn2 - W
fn2 - o
fn2 - r
fn2 - l
fn2 - d
fn2 - !
fn3 - Hello World!
fn3 - ello World!
fn3 - llo World!
fn3 - lo World!
fn3 - o World!
fn3 - World!
fn3 - World!
fn3 - orld!
fn3 - rld!
fn3 - ld!
fn3 - d!
fn3 - !
fn4 - H
fn4 - e
fn4 - l
fn4 - l
fn4 - o
fn4 -
fn4 - W
fn4 - o
fn4 - r
fn4 - l
fn4 - d
fn4 - !
I hope this helps you to understand pointers and their uses.
As you can see the way you prototype a function (char *p) or (char p[]) has no effect on the way pointers operate.
You will probably want to insure that the loops end after some arbitrary number of itterations so that the loops don't go longer than expected but longer than expected is a subjective evaluation.
As you may or may not have realized by using pointers you are altering some area of storage off somewhere that may have unexpected results if the strings are not terminated properly. A non destructive way to determine this is to pass the string pointer to the function strlen() and make a decision based on the return value. In this way you have not already altered some storage off somewhere before you realize that this is getting to be a very long string.
*/
|
|
|
|