|
Hi,
I was just looking around, and I found this http://www.codeproject.com/useritems/PreventClose.asp[^]
I'd like to warn you, it's not the best written article i've read on CP
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Thats nice. I'm still wanting to know why he wants the app to not appear in task manager. I can't see any reason to do this, other than if it's a malicious app, which is why I'm not going to help yet.
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"
|
|
|
|
|
I am creating an application in VC++ which can communicate with Internet Explorer.For eg:- I want my application to know which site is being accessed from Internet Explorer and control Internet Explorer through my application.I want to Know which MFC class to use for this purpose. I would be very thankful to any person who could help me in this matter.
|
|
|
|
|
One solution is COM via IWebBrowser2 ActiveX control.
Kuphryn
|
|
|
|
|
I found this project in the code project archives but I'm getting the error messages at the bottom. I was hoping someone might give me a hand getting this going. Am I missing a header or something? Thanks, Dave
<br />
<br />
<br />
<br />
#ifndef _MT <br />
#define _MT <br />
#endif <br />
<br />
#include "stdio.h" <br />
#include "windows.h" <br />
#include "process.h" <br />
#include "resource.h" <br />
<br />
bool bDone = false; <br />
<br />
void InputThreadProc( void *dummy ) <br />
{ <br />
HWNDhWnd = ::CreateDialog(NULL,<br />
MAKEINTRESOURCE(IDD_DIALOG),NULL,NULL); <br />
if ( hWnd!=NULL ) <br />
{ <br />
::ShowWindow(hWnd,SW_SHOW); <br />
} <br />
else <br />
{ <br />
printf("Failed to create dialog\n"); <br />
bDone = true; <br />
return; <br />
} <br />
MSG msg; <br />
while(1) <br />
{ <br />
if ( ::PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE) ) <br />
{ <br />
if ( msg.message==WM_KEYUP ) <br />
{ <br />
int nVirtKey = (int) msg.wParam; <br />
if ( nVirtKey==VK_ESCAPE ) <br />
{ <br />
HWND hEdit = ::GetDlgItem(hWnd,IDC_EDIT); <br />
if ( hEdit ) <br />
{ <br />
char pText[3201]; <br />
int nSize = ::GetWindowText( hEdit, <br />
pText, 3200 ); <br />
pText[nSize] = 0; <br />
printf("\nYou have entered the "); <br />
printf("following text in a second ");<br />
printf("thread:\n\n%s\n\n",pText);<br />
} <br />
else <br />
{ <br />
printf("Failed to get edit control\n"); <br />
} <br />
::DestroyWindow(hWnd); <br />
bDone = true; <br />
break; <br />
} <br />
} <br />
::TranslateMessage(&msg); <br />
::DispatchMessage(&msg); <br />
} <br />
else <br />
{ <br />
::Sleep(100); <br />
} <br />
} <br />
} <br />
<br />
void main( int argc, char** argv ) <br />
{ <br />
printf("Hello, world of console apps\n"); <br />
if( _beginthread(InputThreadProc, 0, NULL )==-1) <br />
{ <br />
printf("Failed to create thread"); <br />
return; <br />
} <br />
while ( !bDone ) <br />
{ <br />
::Sleep(3000); <br />
printf("main thread running\n"); <br />
} <br />
} <br />
<br />
<br />
---------------------------------------------------------<br />
--------------------Configuration: console_window - Win32 Debug--------------------<br />
Compiling...<br />
console_window.cpp<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(20) : error C2065: 'HWNDhWnd' : undeclared identifier<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(21) : error C2065: 'IDD_DIALOG' : undeclared identifier<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(21) : error C2440: '=' : cannot convert from 'struct HWND__ *' to 'int'<br />
This conversion requires a reinterpret_cast, a C-style cast or function-style cast<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(22) : error C2065: 'hWnd' : undeclared identifier<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(47) : error C2065: 'IDC_EDIT' : undeclared identifier<br />
Error executing cl.exe.<br />
<br />
console_window.exe - 5 error(s), 0 warning(s)<br />
<br />
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
In line 20, change HWNDhWnd to HWND hWnd .
IDD_DIALOG and IDC_EDIT should be defined in resource.h. You have created a dialog resource with those IDs have you not?
ps. why do people rate a question a 1? If the question is so dumb, and the answer so obvious, then answer the question or else totally ignore it and move on.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I actually answered this a few minutes after he posted it, but my reply got posted on the last page of the forum. Wierd...
PJ Arends wrote:
why do people rate a question a 1? If the question is so dumb, and the answer so obvious, then answer the question or else totally ignore it and move on.
I did both - rated it a 1 and posted a reply, which unfortunately got lost
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"
|
|
|
|
|
Ryan Binns wrote:
I did both - rated it a 1 and posted a reply, which unfortunately got lost
It's probably Karma dude...
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
"I suppose if it was a choice between bon jovi and the interior of a car, the car would win, even it didnt have a radio and I had to sit in silence" James Simpson on Light Metal.
|
|
|
|
|
adamUK wrote:
It's probably Karma dude...
Probably. I must have been punished for voting it a 1, even though I voted after I replied...
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"
|
|
|
|
|
Wow... pre-Karma or deja-karma.. now that's spooky.
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
"I suppose if it was a choice between bon jovi and the interior of a car, the car would win, even it didnt have a radio and I had to sit in silence" James Simpson on Light Metal.
|
|
|
|
|
I did what you said PJ and it eliminated 3 of the errors, now I only have 2 errors left...see below. I'm not sure what a dialog is. I thought specifying the header was enough, no?
Thanks, Dave
<br />
--------------------Configuration: console_window - Win32 Debug--------------------<br />
Compiling...<br />
console_window.cpp<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(21) : error C2065: 'IDD_DIALOG' : undeclared identifier<br />
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(47) : error C2065: 'IDC_EDIT' : undeclared identifier<br />
Error executing cl.exe.<br />
<br />
console_window.exe - 2 error(s), 0 warning(s)<br />
<br />
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
DaveE9th wrote:
I'm not sure what a dialog is.
Oh boy
A dialog is a form based window that is used to get input from a user. The colour picker, font picker, and file open/save dialogs that you encounter frequently are examples of dialogs.
Check out these articles for a good beginners intro to using dialogs
http://www.codeproject.com/dialog/dialogapptute.asp[^]
http://www.codeproject.com/dialog/dialogapptute2.asp[^]
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote:
You have created a dialog resource with those IDs have you not?
I'm not sure what you mean by "dialog resource." I know what a dialog box is, I should have been more specific.
I found this project in the archives. It builds a window in a CONSOLE program. You referred me to the MFC tutorials, that's a different ball game. I'm just trying to study the differences between the type of programs. I still can't get the above program going. It wants something in the header file. Anyone?
Thanks much, Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
VC++ needs the dialog resource file which it should have got from resource.h.
If you used the wizard to create a simple application and then pasted the code, then it may have created the resource.h for you, but it is empty, and you should create a dialog with the id that is missing...
Sorry that I can't be more specific, but it is ages since I last used resources.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
I found this project in the codeproject archives but I'm getting the error messages at the bottom. I was hoping someone might give me a hand getting this going. Am I missing a header or something? Thanks, Dave
[code]
/********************** test.cpp **************************/
// define _MT so that _beginthread( ) is available
#ifndef _MT
#define _MT
#endif
#include "stdio.h"
#include "windows.h"
#include "process.h"
#include "resource.h"
// global flag
bool bDone = false;
// this function is called by a new thread
void InputThreadProc( void *dummy )
{
// create the dialog window
HWNDhWnd = ::CreateDialog(NULL,
MAKEINTRESOURCE(IDD_DIALOG),NULL,NULL);
if ( hWnd!=NULL )
{
// show dialog
::ShowWindow(hWnd,SW_SHOW);
}
else
{
printf("Failed to create dialog\n");
bDone = true;
return;
}
// message loop to process user input
MSG msg;
while(1)
{
if ( ::PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE) )
{
if ( msg.message==WM_KEYUP )
{
int nVirtKey = (int) msg.wParam;
// if the user pressed the ESCAPE key, then
// print the text the user entered and quit
if ( nVirtKey==VK_ESCAPE )
{
// get the edit control
HWND hEdit = ::GetDlgItem(hWnd,IDC_EDIT);
if ( hEdit )
{
// get the input text the user entered
// and print it to the console window
char pText[3201];
int nSize = ::GetWindowText( hEdit,
pText, 3200 );
pText[nSize] = 0;
printf("\nYou have entered the ");
printf("following text in a second ");
printf("thread:\n\n%s\n\n",pText);
}
else
{
printf("Failed to get edit control\n");
}
// destroy the dialog and get out of
// the message loop
::DestroyWindow(hWnd);
bDone = true;
break;
}
}
// process message
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
// if there is no message to process,
// then sleep for a while to avoid burning
// too much CPU cycles
::Sleep(100);
}
}
}
void main( int argc, char** argv )
{
printf("Hello, world of console apps\n");
// create a new thread to allow user input
if( _beginthread(InputThreadProc, 0, NULL )==-1)
{
printf("Failed to create thread");
return;
}
// wait for the new thread to finish
while ( !bDone )
{
// sleep 3 seonds
::Sleep(3000);
printf("main thread running\n");
}
}
/************************** end ************************/
---------------------------------------------------------
--------------------Configuration: console_window - Win32 Debug--------------------
Compiling...
console_window.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(20) : error C2065: 'HWNDhWnd' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(21) : error C2065: 'IDD_DIALOG' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(21) : error C2440: '=' : cannot convert from 'struct HWND__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(22) : error C2065: 'hWnd' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\console_window\console_window.cpp(47) : error C2065: 'IDC_EDIT' : undeclared identifier
Error executing cl.exe.
console_window.exe - 5 error(s), 0 warning(s)
[/code]
|
|
|
|
|
I an use the function Drawtextw output some words,
Is this function in the windows98 support?
if it not support, Should I how do?
|
|
|
|
|
I'd suggest you start with msdn.microsoft.com. The full answer to your question is easily found there.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Yes, using the Microsoft Layer for Unicode. See MSDN for more information on using 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"
|
|
|
|
|
but I want to display unicode character in windows 98, what should I do?
|
|
|
|
|
Alice80 wrote:
what should I do
Search for "Microsoft Layer for Unicode" on MSDN.
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"
|
|
|
|
|
I am in a Dialog use pView->ReplaceSel(szData1,true) insert a Unicode char to view,I can't insert it rightly, the some word sign shows the disorderly code after inserting.
What my engineering use is not the method of unicode.
how I can insert these unicode characters rightly?
|
|
|
|
|
Is it because your OS doesn't support the UNICODE?
I know only NT , 2000 and XP automatially support UNICODE.
Win98 and below I think it is not automatically available.
|
|
|
|
|
My os is widows 2000 server,I can output the character rightly use the following code in a dialog,
i is a interger between 0 and 65536
wchar_t cTemp=i;
::DrawTextW(HDC(*pDC), &cTemp, 1, rcText, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
but I cant't output them in a view rightly use this code pView->ReplaceSel(szData1,true);
|
|
|
|
|
Here are portions of my code. The rest of the program is working fine, but at strategic spots I'd like to see what the state of certain values are (shown together in one convenient way).
Where the structure is being initialized, data are already in the variables from which it gets initialized.
======================================
struct IData
{
char* str;
char* pO;
char* pGH;
char* pIntrm;
int wrdlen;
int lvlcnt;
int ltrcnt;
} idata, *pIData;
// other program code
ostream& operator<< (ostream& outp, const IData IDat)
{
char Bufr[40] = " ";
char* Ptr_fmt[] = { pIData->str, pIData->pO, pIData->pGH, pIData->pIntrm };
int i, Dec_fm[] = { pIData->wrdlen, pIData->lvlcnt, pIData->ltrcnt };
i = sprintf(Bufr, "\tstr: 0x%x\n", *Ptr_fmt);
i += sprintf(Bufr+i, "\tOutput: 0x%x\n", *(Ptr_fmt+1));
i += sprintf(Bufr+i, "\tGrp Hold: 0x%x\n", *(Ptr_fmt+2));
i += sprintf(Bufr+i, "\tInterim: 0x%x\n", *(Ptr_fmt+3));
i += sprintf(Bufr+i, "\tWord len: %d\n", *Dec_fm);
i += sprintf(Bufr+i, "\tLevel cnt: %d\n", *(Dec_fm+1));
i += sprintf(Bufr+i, "\tLetter cnt: %d\n", *(Dec_fm+2));
outp<< IDat;
return outp;
}
// other program code
for(int lvl_cnt=0; lvl_cnt<<wordlen; ++lvl_cnt)
{
ltr_cnt = ++lvl_cnt;
pIData->str = str;
pIData->pO = pOut;
pIData->pGH = pGH;
pIData->pIntrm = pIntrm_str;
pIData->wrdlen = wordlen;
pIData->lvlcnt = lvl_cnt;
pIData->ltrcnt = ltr_cnt;
cout<< "\n *** " << idata <<endl;
lvl_cnt--;
}
======================================
In the "for" statement, I had to use two "<" signs, because without it the CodeProject editor would not show the rest of the statement.
After a while, things begin to get blurred. So, I thank you for whatever you may see as the reason why nothing gets shown.
William
Fortes in fide et opere!
|
|
|
|
|
Your operator<< is not sound. First, you're overrunning Bufr , you'll need much more than 40 characters for all that output. Second, you're not doing anything with Bufr . Third, it has a parameter IDat that you don't use; instead you refer to pIData .
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|