|
Towards the end of your application InitInstance method,
the following lines exit
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
Changing the show (SW_SHOW) to hide (SW_HIDE) or something similar will prevent the window from showing. It will actually initial show and then hide. If you wish to prevent this too, you may have to take care of the actual creation functions in the mainframe class.
|
|
|
|
|
This may have been covered in a previous post, but I don't know because there are just too many previous posts to wade through.
I am trying to print a bitmap graphic that is generated from data. It is in a view, so currently I am just printing the view using the whole doc/view printing made easy functions. Actually, I didn't even have to do any programming at all because somehow it was all set up pretty well already just by the MFC standards. Only I have two imposing problems:
1) My bitmap's y axis is reversed or something, because it isn't just printed upside-down, it is printed with the entire y-axis completely reversed, but the x-axis normal. So my graphic is innacurate.
2) My bitmap is being printed really tiny, which makes it hard to see. Because it is generated from data, it needs to be able to be seen clearly.
So can anyone help me flip the y-axis and enlarge it when it gets printed but leave my view as it currently is (unflipped and not enlarged)? I can't seem to find any useful information on how to do either, because I'm not working with text. Any help would be appreciated.
If you would like to email me, you can do so at: ALeonard@bruker-axs.com
|
|
|
|
|
get the picture into a DC..
then use some code like this...
CPrintDialog printdlg(false, NULL); // instantiate the printer dialog
if (printdlg.DoModal() != IDOK) // show the printer setup dialog
return;
CDC srcDC; // this needs to be the image
HDC hDC = printdlg.GetPrinterDC(); // get a DC to the printer
CDC pDC;
pDC.Attach(hDC); // attach the printer dc to a CDC
pDC.StartDoc("printing"); // start the document
pDC.StartPage("page 1"); // start the current page
int width = 500 // image width
int height // image height
// this next function will stretch the image to full size (as it is displayed)...
pDC.StretchBlt(0, 0, width * 3, height * 3, &srcDC, 0, 0, width, height, SRCCOPY);
pDC.EndPage();
pDC.EndDoc();
==================
The original message was:
This may have been covered in a previous post, but I don't know because there are just too many previous posts to wade through.
I am trying to print a bitmap graphic that is generated from data. It is in a view, so currently I am just printing the view using the whole doc/view printing made easy functions. Actually, I didn't even have to do any programming at all because somehow it was all set up pretty well already just by the MFC standards. Only I have two imposing problems: 1) My bitmap's y axis is reversed or something, because it isn't just printed upside-down, it is printed with the entire y-axis completely reversed, but the x-axis normal. So my graphic is innacurate. 2) My bitmap is being printed really tiny, which makes it hard to see. Because it is generated from data, it needs to be able to be seen clearly.
So can anyone help me flip the y-axis and enlarge it when it gets printed but leave my view as it currently is (unflipped and not enlarged)? I can't seem to find any useful information on how to do either, because I'm not working with text. Any help would be appreciated.
If you would like to email me, you can do so at: ALeonard@bruker-axs.com
|
|
|
|
|
I did exactly what you have said to do here. But, apparently some printers do not support
dc.StretchBlt (). They did before because my code worked for about a year. I don't know
what happened but it stopped working.
I am now trying as follows (with little success):
HANDLE hBitamp = ::CreateCompatibleBitmap (printerDC, width, height);
memDC.SelectObject (hBitmap);
// do some drawing into the printerDC
CBitmap it;
it.Attach (hBitmap);
unsigned char *bits = new unsigned char [640*480];
it.GetBitmapBits (640*480, bits);
::StretchDIBits (printerDC.GetSafeHdc (),.... bits,....);
And it does most of what I want. The image is flipped about the Y axis, but that's not a
problem. But, none of the line graphics appear. Any ideas?
Thanks,
Mike
|
|
|
|
|
how do you add items (subitems) under a column header in a CListView control?
if you don't understand my question, please look at the image I attached. it should explain it.
|
|
|
|
|
ListView_SetItemText(GetDlgItem(IDC_YOURLISTIVEW), iRowNumber, iColNumber,"Text");
==================
The original message was:
how do you add items (subitems) under a column header in a CListView control? if you don't understand my question, please look at the image I attached. it should explain it.
|
|
|
|
|
how do you add items under column headers in a CListView (using report view). ie: subitems
|
|
|
|
|
after i highlight the text the text will be able to change colour
so i can know that the text has been highlight before
|
|
|
|
|
I have a child program that is opened by a parent app. This child program is actually a seperate fully
functional program (such as a game) that is executed as a child program of the parent. This
child program has user buttons on it, how would I get my parent app to send a click event to this
user button contained within the child program?
|
|
|
|
|
I'm trying to build a simple ActiveX server control for use in my ASP pages.
The coding part is going just fine, but the stopping and rebooting of my web servers is driving me crazy.
If I just try to do a NET STOP on all the web services, the .dll *will* unload and I can copy it over, but when I try to do a NET START I get a 1068 error saying one of the support services failed to load. Which requires me to reboot the machine before I can get it working again.
I've been searching through MSDN (which usually answers my questions just fine, but I can't find anything about remote compiling and stopping/starting the web services).
If anyone has a better method, I'd love to hear it.
|
|
|
|
|
I'm trying to build a simple ActiveX server control for use in my ASP pages.
The coding part is going just fine, but the stopping and rebooting of my web servers is driving me crazy.
If I just try to do a NET STOP on all the web services, the .dll *will* unload and I can copy it over, but when I try to do a NET START I get a 1068 error saying one of the support services failed to load. Which requires me to reboot the machine before I can get it working again.
I've been searching through MSDN (which usually answers my questions just fine, but I can't find anything about remote compiling and stopping/starting the web services).
If anyone has a better method, I'd love to hear it.
|
|
|
|
|
When I add buttons to CMDIChildWnd I cannot tab between them, but the buttons respond on mouse. How make the tab key working ?
|
|
|
|
|
Hello -
I've a client application. The server sends data packs through a stream socket. It works very well for clients running on WinNT and Win95/98. But for some how, when I run the client in a Win2000 PC, whenever the server sends a specific large message (large compared with the other messages, but it's about only 650 bytes long) the client side gets a disconnection notification with error WSAENOBUFS.
I don't believe socket buffer are this small in Windows 2000. Does anyone out there have any clue... tip... trick?
Thanks in advance.
Best regards.
- Thales
|
|
|
|
|
I want to add some GIF (and animated GIF) files to my dialog app. Does anybody knows some links/source samples, where I could get inspiration? Please let me know. Thanks for your help.
|
|
|
|
|
Hmmmmm!
Do you really know about the licensing issue involved in using GIF in an application?
Please forget this and try animated icons, or take control and do a complete bitmap selection/rotation yourself, see MS debugger sample DEB for illustration.
Regards,
Paul.
|
|
|
|
|
Hi Forum,
I would like to set a bitmap (sign of firm) in the frame of the mainframe of a mdi-document! normaly its windows-default gray.
Have somebody a solution?
Thanks!
|
|
|
|
|
Here's the solution from The MFC Answer Book by Eugène Kain:
- Create a new CWnd-derived class (we'll call it CMdiBackground). This will be used to subclass the MDI client window.
- Add handlers to this class for WM_ERASEBKGND and WM_SIZE.
- In OnEraseBkgnd, call CWnd::OnEraseBkgnd() and then do whatever custom painting you want.
- Your OnSize() handler should call CWnd::OnSize(), followed by Invalidate(TRUE).
- Add a CMdiBackground member variable (call it m_wndMdiBackground) to your CMainFrame class.
- Add this code to the end of CMainFrame::OnCreate()
if ( !m_wndMdiBackground.SubclassWindow(m_hWndMDIClient))
{
return -1;
}
--Mike--
==================
The original message was:
Hi Forum,
I would like to set a bitmap (sign of firm) in the frame of the mainframe of a mdi-document! normaly its windows-default gray. Have somebody a solution?
Thanks!
|
|
|
|
|
Hello,
My codes at the following does this and more!!!
http://www.codeproject.com/docview/mditab.asp
Regards,
Paul.
|
|
|
|
|
I have created a custom control in a DLL and it works perfectly when used in a
dialog box or property page.
However, if I try to use the control in a view window, I get infinite recursion.
The following window procedure is straight out of David Kruglinksi:
LRESULT CALLBACK AFX_EXPORT
OCTimeslotCtrlWndProc(HWND h_wnd,UINT message,WPARAM w_param,LPARAM l_param)
{
CWnd* p_wnd;
p_wnd = CWnd::FromHandlePermanent(h_wnd);
if (p_wnd == NULL)
{
//
// first-time; a new window has been created
//
p_wnd = new OCTimeslotCtrl;
p_wnd->Attach(h_wnd);
ASSERT(p_wnd == CWnd::FromHandlePermanent(h_wnd));
}
ASSERT(p_wnd->m_hWnd == h_wnd);
LRESULT l_res = AfxCallWndProc(p_wnd,h_wnd,message,w_param,l_param);
return (l_res);
}
As I said, this works fine when the control is used in a dialog box. However, when used
in a view, the call to AfxCallWndProc simply indirectly recurses back to OCTimeslotCtrlWndProc.
A stack overflow immediately occurs.
Does anyone know how to get a custom control in a DLL to work everywhere?
|
|
|
|
|
I want to give people a 30 day working version of software that I write and after which time, if they haven't entered the correct password then the program fails to execute.
If I just hardcode some password like 'duckpond', then what stops an individual from giving that password to
someone else? Nothing.
I am confused and frustrated. Please, any response you can give me will be greatly appreciated. Details and a sample project would be cherished.
Sincerely,
Erich J. Ruth (an overworked graduate student)
|
|
|
|
|
Hi!
When the program starts for the first time you can add the item in the registry with the date of the first use and check it all the time the program starts.
Concerning the password you can use different techniques... For example, at the first run you can generate a unique serial number for the program and save it in the registry (it can be a GUID). Later when the version expires the user will have to send (tell) you the serial number and you will give him the password which will work only with this serial number. You can easily make a password out of the serial number.
In this case if the user will run this program on the different computer he will need a different password.
It's just an idea, but it can help you ...
Regards,
Alex Gorev,
Dundas Software.
==================
The original message was:
I want to give people a 30 day working version of software that I write and after which time, if they haven't entered the correct password then the program fails to execute.
If I just hardcode some password like 'duckpond', then what stops an individual from giving that password to someone else? Nothing.
I am confused and frustrated. Please, any response you can give me will be greatly appreciated. Details and a sample project would be cherished.
Sincerely, Erich J. Ruth (an overworked graduate student)
|
|
|
|
|
Don't do this with a hardcoded password. Use the registry, and an install program.
First step. When you install the software with the install program, and you setup all your default registry settings, add a new registry item (call it something inconspicuous).
Second Step. Get a GUID number and the date you are doing the installation. Using a (secret) calculation, merge these two numbers together, and store them both in the registry.
Now when you start your program, get the current date. Calculate the install date from the registry data, and work out how many days are left for the user to use your software.
Of course there are many other possible methods. This is just one way, there may be a way which suits you better. Of course you could always just store the install date in the registry, but there is nothing to stop someone changing it. For that matter theres nothing stopping someone really determined from cracking the method I just described.
Good Luck.
|
|
|
|
|
As you say, "there's nothing stopping someone really determined...."
I experimented with a similar method a while ago. I generated a GUID and stored the install date in a binary form under the GUID in HKEY_CLASSES_ROOT (where I thought it would be inconspicuous).
It all worked well until I ran a registry cleaning program which spotted the entry as "orphaned" and offered to remove it.
The moral being of course, try to crack it when you've written it, and if your succeed, try something else.
Even better, try a combination of approaches - writing an encrypted file to Windows\System32 may be a good idea as well.
|
|
|
|
|
Hi,
I have do a console program with Visual C++ 5.0.
When I run this program from the Visual IDE, the console program run in a DOS window.
When the program is terminated , the DOS window keeps open.
When I run the same console program from the Explorer or from the desktop, the DOS window
automatically close when the program is finish.
How can I get the DOS window still opened when my console program ends?
(I can do this with a batch file, but I want to know if it is possible without a batch file)
I have check the properties and I get only one or two tabs. I can't control the screen.
Thanks,
Claude
|
|
|
|
|
Hello,
This is the trick. VC++ does not directly run your application. Instead it hands it over to another console application vcspawn.exe in the VC++ bin directory. This executes your program as a process and wait till it completes and then prints
"Press any key to continue".
It then immediately sets itself to receive an input from the user and any key pressed is enough to get it to the end of its main().
To simply emulate this, at the end of your main(), do something similar to
int main()
{
.....// your main code ends here
// End of main processing
cout<<"Press any key to continue..."<
|
|
|
|
|