|
Sure. Just use sizeof() in a standard (2**n - 1) calculation to get the most -ive and most +ive number that can be stored in an int . Imho, that's the real programmatic way of figuring this out.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Dear All,
Code project people has helped me a lot during my initial career by flooding me with useful solutions & valuable comments to my doubts. Thanks a lot for that.
I have another small question. I am developing an application in which I am running an executable (the job of this exe is to move some files from one location to the other, etc.). This exe is built using "Win32 Console application" provided in Visual C++ Version 6.0
When I run the application, it calls my exe, and this running exe shows its console window and performs its required operation successfully and close downs decently. BUT I DONOT WANT THAT CONSOLE WINDOW TO BE DISPLAYED DURING MY APPLICATION.
I cannot change the application since I don’t have the code for that, but I can easily do the same for my exe. So can any body please tell me how to hide the console window or console should not be displayed.
Regards,
Rohit Dhamija
|
|
|
|
|
In VB, it would be simple:
Shell "foobar.exe", vbHide
modified on Monday, August 30, 2010 6:46 AM
|
|
|
|
|
See the Console class on my website www.xfcpro.com, under the freestuff section for the full code, but here is a sample of what you need to do.
HWND Console::GetConsoleWindow9X()
{
HWND hWndConsole = NULL;
TCHAR szTempTitle[_MAX_PATH];
TCHAR szTempOldTitle[_MAX_PATH];
if(GetConsoleTitle(szTempOldTitle, _MAX_PATH) > 0)
{
WCHAR szBuff[_MAX_PATH];
memset(&szBuff, 0, _MAX_PATH);
GUID obGuid;
CoCreateGuid(&obGuid);
StringFromGUID2(obGuid, szBuff, _MAX_PATH);
wsprintf(szTempTitle, "%ws", szBuff);
SetConsoleTitle(szTempTitle);
Sleep(50);
if((hWndConsole = FindWindow(_T("tty"), szTempTitle)) == NULL)
if((hWndConsole = FindWindow(_T("ConsoleWindowClass"), szTempTitle)) == NULL)
hWndConsole = FindWindow(NULL, szTempTitle);
SetConsoleTitle(szTempOldTitle);
}
return hWndConsole;
}
void Console::ShowConsoleWindow(bool bHide )
{
HWND hWndConsole = NULL;
#if(_WIN32_WINNT >= 0x0500) // Windows 2000 and later only
hWndConsole = GetConsoleWindow();
#else
hWndConsole = GetConsoleWindow9X();
#endif
ShowWindow(hWndConsole, (bHide) ? SW_SHOW : SW_HIDE);
iLastErrorCode_ = XFC_SUCCESS;
}
regards,
Dark Angel
|
|
|
|
|
Thanks Dear,
I am developing my application only for Windows2000 (no Win9x systems)
So I there any simpler way out for my doubt ??
Thanks a lot.
Regards,
Rohit Dhamija
|
|
|
|
|
Hi Rohit,
For Windows 2000 just add the following function to your code and call it at the start of your application.
void ShowConsoleWindow(bool bHide )
{
ShowWindow(GetConsoleWindow(), (bHide) ? SW_SHOW : SW_HIDE);
}
Then to hide the console window, call:
<code>
ShowConsoleWindow(true);
and to show it again (if necessary):
<code>
ShowConsoleWindow(false);
best wishes,
Dark Angel
|
|
|
|
|
Hello,
in my application I use the activex component msflxgrd.ocx. I use it in a dialog and in a view. At a PC without visual c++ installed I only can see the component in the dialog not in the view. I copy the component in C:\Winnt\system32, and I register it.
Do I need some dll or library?
Thank you.
|
|
|
|
|
Hi,
I need to simulate the process OS detecting the device when is it connected to system thru USB port and loads a driver. OS should treat my application as a device and load its driver..plz any one help me out this .
|
|
|
|
|
hi ,
i have the following problems... would be gratefulif you could kindly give me some suggestions.....
1)i have a dialog based application in which i have to implement a scroll view .. can i use CSrollView(i suppose i cant)..if not how do i do it..if yes then how do i do it
2)i have to capture the entire image irrespective of being within the viewable region or not ....how do i go about it....
plesae help...
Thanking you.
Satadru
|
|
|
|
|
1) to use Views in a Dialog there is a splended article in MSDN with sample code that should help
( but i can't figure out why you have to use CScrollView it doesn't provide anything else other than scrolling support
you can use scroll bars on the dialog instead)
2)if that image is not completely displayed than you cannot capture it (it would be like , you give the application ur DC and ask it to paint on it )
but you can try to get that window's DC and Bitblt (might work)
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
hi ,
thanks for the help cud u please tell me which article is that.... i have another problem..
from my main dialog iam creating another dialog and popping it....from this second dialog i have to access members of the main dlg ... how do i go about it ... i have tried DYNAMIC_DOWNCAST but it isnt working in my compiler ... any way ouy...
Thanking you.
Satadru
|
|
|
|
|
class CAnotherDlg .....
{
CDialog *m_pPrevDlg;
}
CFirstDialog :: OnInitDialog()
{
CAnotherDialog dlg;
dlg.m_pPrevDlg = this;
dlg.DoModal();
}
now whenever you use the m_pPrevDlg just cast it and use it
((CFirstDialog*)m_pPrevDlg)->FireAway();
(Don;t forget to include the firstdialog.h )
as for not finding the article it is by Paul dilascia and it show how to use CHTMLView in a dialog
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Hello guys,
I am still having trouble to catch "Enter" (Return) key press from a PC keyobard in my app. I think the problem mainly comes from the fact that the app has a parent dialog with serveral embedded child dialogs (only one child dialog is shown at a time on the app window, different child dialog is shown using ShowWindow(SW_SHOW), ShowWindow(SW_HIDE).
Preferrably, I want the child dialogs to catch the "Enter" key press. So what I did, was first, "return 0" in the parent class' OnInitDialog() and set the focus to the appearing child's DDX control, say a CButton, in the child class' OnShowWindow().
With the above method, I can get the focus set (using SetFocus()) to each desired CButton in the child dialogs and I can cycle through the buttons (if there are multiple) in each shown child dialog using arrow keys. However, none of the buttons will not respond to "Enter" key, but only "Spacebar" key to perform OnBnClicked() function. If I "tab" to the button that belong to the parent dialog, pressing the "Enter" key will call the OnBnCliked(). Can anyone explain why?
Also, I tried to see if the Enter key is caught in the child class by overriding its OnOk() or OnKeyDown() but the key pressed doesn't seem to go through them either.
|
|
|
|
|
i don't understand you! but i think this may be help you:
BOOL CMyCTIDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
if(pMsg->wParam==VK_ESCAPE||pMsg->wParam==VK_RETURN)
return true;
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
Thanks alot for the reply, taiozi.
And apologies for the badly phrased post, I wrote that in a rush. I have rewritten it. Would appreciate if you could give it one more read and see if you can understand it now
However, the PreTranslateMessage() you mention here might be what I am looking for, I will try that in my child dialogs' classes. Will report back.
Thanks again
|
|
|
|
|
Thanks tiaozi,
with your help (the code), I can correctly catch the Enter key press(VK_RETURN) and tell if it's caught by the parent dialog or the embedded child chialog. Now I realise when the app was initially load, the key press is always caught by the parent, although a button in the child dialog has been highlighted (here I'd think so the focus is set to the child dialog?).
Do you know how I can correctly set the focus to child dialog when the app is loaded? I've tried two different ways, none of them seem to work.
One is to place pChildDlg->SetFocus() in the parent class' OnInitDialog(). pChildDlg is the pointer to the child dialog that is showing.
Two is to place SetFocus() in the child class' OnShowWindow(), whether to the child itself (thus this->SetFocus(); ) or a control (in my case, to a CButton). Here as I mentioned earlier, when I SetFocus() to the CButton, I can see the button is highlighted as the app window is initially loaded. But when I hit "Enter" key, this input message is still caught by the parent?
|
|
|
|
|
OK, I got it working, with the second method (after some fix). I forgot to put ON_WM_SHOWWINDOW() message map in.
|
|
|
|
|
I know that TextOut method helps displays strings...what if i want to display integer/float? Do I have to convert it to string n use TextOut? Or is there another available method?
Thank you
|
|
|
|
|
i'm not sure if TextOut directely accepts integers, but you can use the 'Format' method of CString to construct a string from an integer (or float, double etc.). Hope this helps.
Er zit een korstje op mijn aars.
|
|
|
|
|
Thanks for d reply...just to confirm. So, there is no other method to display integers than to convert it to string. Is it?
Thanks again.
|
|
|
|
|
char buff[25];
sprintfbuff,"%d",m_yourInteger);
pdc->TextOut(buff);
hope this works for you, if you need some other stuff, do let me know.
regards
balkrishna talele
|
|
|
|
|
BOOL TextOutF(HDC hDC, int x, int y, LPCTSTR szFmt, ...)
{
TCHAR szOutput[512];
va_list args;
va_start(args, szFmt);
_vsntprintf(szOutput, 512, szFmt, args);
va_end(args);
return TextOut(hDC, x, y, szOutput, _tcslen(szOutput));
}
Now you can write:
int nMyInt = 34;
TextOutF(hDC, 0, 0, "my int = %d", nMyInt);
Output:
"my int = 34"
|
|
|
|
|
No, You have to convert it to a string and then print it. You can use CString Format method or wsprintf or sprintf and create the formatted string then use it to display the msg.
|
|
|
|
|
Hello Sir...
Sir..My requirment is to insert first page in Tiff which is created by user in CScrollView...
Please Suggest me any solution How can I do...
I'm using LibTiff...
As your've also used Libtiff in your project..this means u can better Suggest me...
I'm Very thankful to u if u provide me short function which convert SrollView to Image & place in Tiff as first Page...
Also I Suggest me How can I modify Tiff file...e.g: I want to change or Insert Text in Particular position In First Page of Tiff...
Please Guide me Sir..I'm trying to solve this problem from One week...
I hope U will help me...& I hope u will spare some time from your busy life & Reply me.....I'm waiting reply from U..
So Nice of U..that U listen my problem..& thinking its solution...
Thanks...Sumit
sumit_delhi
|
|
|
|
|
Hi, I hope that this doesn't sound stupid...
I'm currently in first year University... and I'm planning on becoming a software engineer. I picked up Visual Studio.net 2003, and so far I'm doing pretty good... except for one thing. Does anyone know how to statically link visual C++/C# programs when compiling, so that I can distribute the programs that I made to friends who do NOT have Visual Studio.net, or any other programming language for that matter?
Any help would be greatly appreciated.
Thank you.
Mike
|
|
|
|