|
Can anyone advise me on how to make my console program start minimized?
Thanks all
Digital Khaos
"Diplomacy is dead. Feel my wrath!"
|
|
|
|
|
Here is a good starting point:
http://www.codeproject.com/cpp/cppforumfaq.asp#cons_nowindow
|
|
|
|
|
Ok, I appologize for not reading the FAQ. However, how about make the window non-closeable by the user. graying out the X, or something similiar. Is this an administrative function, or can it be done in code?
Thanks again.
Digital Khaos
"Diplomacy is dead. Feel my wrath!"
|
|
|
|
|
Here's one solution for disabling the Close button:
#include <tchar.h>
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam )
{
TCHAR a_szClass[64] = {0};
::GetClassName( hwnd, a_szClass, 63 );
if( !_tcsicmp( a_szClass, _T("ConsoleWindowClass") ) )
{
DWORD a_dwWindowThread = ::GetWindowThreadProcessId( hwnd, NULL );
if( a_dwWindowThread == ::GetCurrentThreadId() )
{
*((HWND*)lParam) = hwnd;
return FALSE;
}
}
return TRUE;
}
void RemoveYourConsoleCloseButton()
{
HWND a_hThisConsoleWindow = NULL;
::EnumWindows( EnumWindowsProc, (LPARAM)&a_hThisConsoleWindow );
if( a_hThisConsoleWindow )
{
HMENU a_hMenu = ::GetSystemMenu( a_hThisConsoleWindow, FALSE );
if( a_hMenu )
{
::RemoveMenu( a_hMenu, SC_CLOSE, MF_BYCOMMAND );
::SetWindowPos( a_hThisConsoleWindow, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_DRAWFRAME );
}
}
}
When you want to disable the close button, call RemoveYourConsoleCloseButton().
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
I would like to write a graphical utility that performs similar trouble shooting functions to the Microsoft utility BROWSTAT.EXE. Can anyone point me in the right direction of material about Windows API functions that can be used? I have several books, MSDN, on-line resources, etc. The only Windows Browsing API functionality I am able to find involves enumerating browse lists. I am hoping to be able to programmatically get/set domain master browsers, manage browse lists, etc… I assume there are API functions that do these things because BROWSTAT and BROWSEMON do. Please help. Thanks.
|
|
|
|
|
The WMI (Windows Management Instrumentation) API should be more than enough (and I guess it's the only way as well) to get the work done. Beware though it's a bit cryptical and has thousands of objects depending on implementation, which might be confusing at first look.
|
|
|
|
|
I'm seeing some strange display problems with CCheckListBox on Win2000.
I have an MFC app which displays a CCheckListBox. The app has been compiled on an XP machine using VS.NET (2002) but with no manifest or theme code. On XP machines the CCheckListBox displays its contents no problem. (Three strings). However on Win2k machines the entries aren't displayed. However if I click on the list box then the items are there, just not being displayed.
Anybody seen this problem before?
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
If I remember well, you have to programatically select one item to have them displayed in the list box, inserting is not enough.
~RaGE();
|
|
|
|
|
Hi all,
My applicaiton needs to look for and use a currently open IE (Using IE 6) and if there's not one, then start one. The problem I'm having is that GetActiveObject will see other programs such as Excel and Word, but it always fails to see IE running. I've tried both the CLSID_InternetExplorer and using the CLSIDFromProgID function. Neither seen to work. I've also read that some Office programs need to loose focus before they register running objects, but that does not seem to help in this case either. Any ideas? Is there something with IE that I'm not setting? Can CoCreateInstance or CoGetClassObject be used to detect? Thanks for any info. -rob.
HRESULT hr;
hr = ::CLSIDFromProgID(L"IExplorer.Application",&prog_clsid);
assert(SUCCEEDED(hr));
hr = ::GetActiveObject(prog_clsid, NULL, &pUnk);
// hr = ::GetActiveObject(CLSID_InternetExplorer, NULL, &pUnk);
assert(SUCCEEDED(hr));
|
|
|
|
|
I just tried that code but used "InternetExplorer.Application" for the ProgID, and it worked fine for me
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
Hi
I have made a new form, derived from CDialog, i've already implemented contextual help ('What is this?').
But i don't seem to be able to get a question mark icon in the title bar of that form. It can't be hard, but i don't find it
Anyone knows?
Greetings
Jens
|
|
|
|
|
Check the Context help checkbox on the Extended Styles tab of the Properties dialog.
|
|
|
|
|
yes it is checked but it doesn't give me the arrow icon on title bar.
|
|
|
|
|
Arrow icon? Do you mean a question mark? According to the documentation, the Context help checkboxes on both the More Styles and Extended Styles tabs are directly related to the question mark in the title bar of the dialog.
|
|
|
|
|
yeah i meant the question mark.
And yes, i checked those 2 already.
But i still don't see it
|
|
|
|
|
I'm at a loss at this point. Perhaps you could create a test application that sports one dialog box. Play with those two "help" checkboxes and then see how the test application differs from the application that does not work.
|
|
|
|
|
The context help style can't be used if the dialog has minimize and/or maximize buttons.
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
the problem was i had to enable 'system menu' in Dialog properties. Now i have the context help style with a 'X' close button next to it .. can i hide the 'X' (close) button and still having the context help style?
Greetings and thanks for the fast response
Jens
|
|
|
|
|
I am hosting user interface components in a com dll. My question is when a user clicks a button on a dialog, where should the code to handle the click reside??
A. The form where the click occurred
B. A business object in which case a sink would have to exist between ui dll and business object dll
C. None of the above in which case i have no clue where to put the code?
Help
Thanks
|
|
|
|
|
As with any dialog, it should have an onclick handler for the button. The code in the onclick handler can then communicate with the business object dll.
|
|
|
|
|
Thanks, I wasn't sure if it was then necessary to add a processing component for the ui to talk to which would in turn call the business component. This would further encapsulate the dialog code but in turn would create a headache as to who holds the reference pointer to the business object.
|
|
|
|
|
Hi,
For binary string i have following loop which calculate the
difference of 0' and 1'.
int CMyDlg::ZeroOneDiff(char *str, int length, char sbit)
{
int i;
char tmp;
char backup[60];
int iZero, iOne;
int iDiff;
tmp = sbit;
memset(backup, 0, 28);
for(i=0; i<length; i++){
if(="" (str[i]="=" '1')="" &&="" (tmp="=" '0'))="" {
backup[i]="1" ;
}
else="" if(="" '1')){
backup[i]="0" if((str[i]="=" '0')="" '0')){
backup[i]="0" '1'))="" ;
}
tmp="backup[i];
}
iZero" =="" 0;
ione="0;
iDiff" 0;
for(i="0;" i<length;="" i++){
if(backup[i]="=" izero++;
else="" ione++;
}
idiff="" +="(iZero" -="" ione);
return="" idiff;
}
for="" example,="" for="" binary="" string="010001000100100" and="" start
bit="" '0',="" we="" can="" call="" above="" function="" as
int="" diff="ZeroOneDiff(string," 15,="" '0');
i="" really="" want="" to="" know="" if="" there="" is="" a="" fast="" method="" doing="" this="" (using="" &,="" |,="" ^,="" <<,="">> operators )? especially, when the length of the binary string is bigger, the fast method is more valuable.
Thanks in advance!
chen
|
|
|
|
|
What does the function do? In other words, what IS the difference between 0' and 1'?
|
|
|
|
|
If the first or start bit is '0', the function translate
the 010001000100100 into
011110000111000
otherwise if start bit is '1', the translated binary string is
100001111000111
and then, calculate the sum of 0 and 1 in the new string
and finally return the difference of 0 and 1:
sum of 0 - sum of 1.
that it!
chen
|
|
|
|
|
I guess I'm just slow but I'm still not clear as to what this is doing. When 010001000100100 is translated to 011110000111000, some of the 0s get translated to 1s while others do not. Likewise, some of the 1s get translated to 0s while others do not.
Since there does not seem to be a linear pattern as to when a 0 gets translated to a 1 and vice-versa, bit-flipping doesn't seem to be a possible solution. I may be wrong on this.
|
|
|
|