|
|
You need to handle OnEraseBkgnd(), because by default if fills the whole client area before OnDraw() is called (flicker flicker). One solution is to disable background erasing and handle all you drawing in OnDraw().
Note: Even if you use a memory DC to try prevent flickering it will still occur if you do not over-ride OnEraseBkgnd().
Trust in the code Luke. Yea right!
|
|
|
|
|
I'm trying to read the command line argument, if the user enters
/s, my program is supposed to do something.
I have:
if(m_lpCmdLine[0] == '/s')
but == does not work for this compare.
m_lpCmdLine[0] is of type LPTSTR. I don't know how to say if the command argument equals /s.
|
|
|
|
|
If your are in MFC,
do something like that in InitInstance():
CString str=GetCommandLine();
if (str.Find("/s")!=-1)
{
code for /s option
}
If not, and your command line is a LPTSTR,
use
if (strstr(m_lpCmdLine[0],"/s")!=NULL)
{
code for /s option
}
You can also use strcmp instead of strstr, but then your command line would be only "/s" to enter the if scope, whereas with this example, you could also have "/s /p -j 897" (it is a substring search, and no direct comparison)).
~RaGE();
|
|
|
|
|
You are almost correct. But remember that when dealing with LPTSTR and TCHAR (as is the case here) you need to use routines from TCHAR.H to avoid problems in Unicode, e.g., _tcsstr instead of strstr and _tcscmp instead of strcmp.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Use strcmp function to compare strings (or wcscmp for UNICODE). Also, the constant you compare to should be written as "/s" (or _T("/s") for UNICODE).
|
|
|
|
|
m_lpCmdLine[0] is a single character. '/s' is two characters. They are obviously not going to match!
|
|
|
|
|
To check if a string equals another one:
if(strcmp(m_lpCmdLine, "/s") == 0) <what-you-wanna-do-if-it-equals> But you shouldn't do it like this. I suggest you use a command line parser like http://www.codeproject.com/cpp/CmdLineParser.asp[^] (excellent one, try it!).
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
if(!strcmp(m_lpCmdLine[0], "/s"))
or
if(strcmp(m_lpCmdLine[0], "/s") == 0)
choose what you want
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You need to use TCHAR routines. Ther eis a corresponding TCHAR routine for each of the standard "str" functions. So to compare:
if(_tcscmp(m_lpCmdLine, _T("/s")) == 0)
{
}
Some of the previous comments about using strcmp are technically incorrect, since it would fail for Unicode builds (LPTSTR is an array of TCHARS, not chars!) But as also noted, this is probably not the best way to parse your command line - take a look at the documentation for ParseCommandLine.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
>> if(m_lpCmdLine[0] == '/s')
You really need to take C again (if you did before).
Take a look how C define:
array [0] and 'c' and "string"
|
|
|
|
|
hi there,
i have a problem. now i am developing an application for our client. One of their requirements is that they want to control page numbers, e.g. the maximum page number is 5, when their users print documents, using MS office familiy, such as Word. How should i do?
Thanks a lot in advance.
Evisoh
|
|
|
|
|
If they are printing directly from Word, you can't control how many pages they print. You can, however, provide your own interface and use Word automation to print the document. Then you can control how many pages are requested.
|
|
|
|
|
unfortunately, they have to print directly from word. I suppose that i can use Hook to intercept printing message, however, i have not seen yet any articles about how to intercept printing message. If you guys knew this, i will appreciate your suggestion.
|
|
|
|
|
hu_jia wrote:
unfortunately, they have to print directly from word.
Then why limit them? What good does it do to have a product if you only want part of it to be used?
|
|
|
|
|
that is a human resource center, and every single their user can get maximum 5 pages of printouts. now it is managed by staff, and keep them very busy because of lots of peopel out there. that's why they want to get it controled by compnters.
|
|
|
|
|
Given that they have full control over Word, I see no solution. Not knowing everything from your vantage point, what I've got so far would dictate giving them a little printing utility that limited the number of pages to five. Good luck.
|
|
|
|
|
i will negotiate with them to find alternative if we find no solution. Anyway, thanks a lot. let's keep in touch.
|
|
|
|
|
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
|
|
|
|