|
Hi,
In my application, I can display Bitmaps.. but i like to get a blank document when i click on
the sub-menu "New".
Does anyone know how?
Thanks
Ehsan Behboudi
|
|
|
|
|
You can Send a Message "ID_FILE_NEW" to the main Frame
In the "new" handler.
Regards,
histimes
|
|
|
|
|
I am grabbing some Bitmaps from an external source and need to and them to the current module to build a menu.
I can add perfectly okay if the Bitmap / Icon in addedd to the current project using LoadBitmap(IDB_MYBITMAP);
but I have a CBitmap object and can't get it to display.
The Bitmap that I am recieving from the external source is a HBITMAP, example:
HBITMAP bm = res2.LoadResourceBitmap(....); /this returns a HBITMAP
The code below is how I set my Menu Bitmaps
SetIcon(1, IDB_EXIT); // the first parameter being the Menu Id Command.
SetIcon(35789, IDB_ABOUT); // the second being the ResourceID for the Icon/Bitmap
Whats the easiest, or should I say, what is any way of being about to add this loaded Bitmap e.i.
SetIcon(ResourceID, CBitmap);
regards,
pgudge
|
|
|
|
|
Programming would be a good way to make a living if it were not for these pesky users.
I work on an application that draws some graphs of data obtained from test instruments. The graphing is done by our own MFC based graph class. It draws onto a CDC object in response to a windows draw message in the normal MFC way. We can render our graphs on the screen or the printer with no problems. There's a lot of code in the class, but it's very standard MFC drawing, nothing unusual.
Just when I thought I was safe to take off early on Friday, management comes up with this: "Hey Jim, our big important customers love our graphs, but they want to be able to save them as jpegs so they can embed them in their word processing documents. Can you hack something up? They are visiting next week and we'd like a demo."
Great.
I have one little problem with this request. I have no idea how to even start!
I'm sure that saving it as a regular uncompressed bitmap would be fine, I have a graphics class that lets me display, save, and print bitmaps in both jpeg and windows bitmap formats.
But how do I get the bitmap in the first place? Is there anyway to have a "bitmap device context"? I'm trying to think, but nothing is happening. I know there are programs that do this, so it must be possible.
Your suggestions and pointers are very welcome.
Jim
|
|
|
|
|
"Bitmap device context" is called "memory device context" in Windows. Check the docs for CreateCompatibleDC.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I have included a c program (driver.lib) which is used as a library for my c++ program (myProgram.exe).
from my c++ program I need to call C functions from driver.lib. I keep getting this compiler error:
LNK2001: unresolved external symbol
I read from the MSDN that I have to use 'extern' to call C functions from a C++ program.
My question is how and where to use it.
A sample code would be wonderful.
thanks in advance
|
|
|
|
|
In your header file containing the C functions
#ifdef __cplusplus
extern "C"
{
#endif
void cFunction(int arg1)
{
...
}
#ifdef __cplusplus
}
#endif
Stephen Kellett
--
C++/Java/Win NT/Unix variants
Memory leaks/corruptions/performance/system problems. UK based.
Problems with RSI/WRULD? Contact me for advice.
|
|
|
|
|
To use a 'C' libary in a 'C++' program, in the header file for the c program, you prefix function declarations with "extern C" preprocessor commands.
For example, if you are using only C++, just do this in driver.h:
extern "C" void ExportedFunction(void* pBlah);
This tells the C++ complier that this function is to be treated as a plain ole 'C' function.
If you have several exported functions in the header file, you don't have write "extern C" for each one, you can use braces:
extern "C"
{
char ShowChar( char ch );
char GetChar( void );
}
If driver.h might also be used by a 'C' compiler, you use the processor to make sure that only the C++ compiler sees the "extern" command:
#ifdef __cplusplus
extern "C"
{
#endif
void ExportedCfunction1(void *pBlah);
void ExportedCfunction2(void *pBlah);
void ExportedCfunction3(void *pBlah);
#ifdef __cplusplus
}
#endif
If you don't want to change driver.h, you can surround the include statement in the cpp file for the driver with the extern command:
// Cause everything in the header file "cinclude.h"
// to have C linkage.
extern "C"
{
#include <cinclude.h> //from MSDN
}
See "Linkage to Non-C++ Functions" in MSDN for more fun with "extern".
Of course you want to be sure that the linker knows where to find driver.lib. In Visual Studio you do this with the project settings->linker.
Jim
|
|
|
|
|
Hello,
I have a CDialog derived dialog box, for which the default behavaior is to close when the user presses the ESCape key. Can anyone tell me how to catch the message (command) that is sent when the user presses ESCape? (I think I should be overriding CWnd::OnCommand(), but I'm not sure which command to catch.)
Thanks!
|
|
|
|
|
You can override CDialog::OnCancel()
|
|
|
|
|
Hi all, I'm stuck and was hoping someone might be able to help. I just put a combobox into a toolbar (Stingray Toolbar) And now I'm trying to think of a way to trap the enter message... Normally I would just make another class, derive it from CComboBox and in the pretranslate handle the WM_KEYDOWN and VK_ENTER... but if I'm putting it in the toolbar I have to use the standard CComboBox.
Anyone know a way I can trigger a method when the enterkey is hit inside a CComboBox?
--Dave
|
|
|
|
|
If you *absolutely* need CComboBox in the toolbar, revert to classic API tricks. Having combo's HWND, subclass it.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello,
I have a problem with distributing cab file. I put two OCX files and INF file in my test.cab file but my control does not appear on other machines. I check folder winnt/downloaded program files adn i do not see my OCXs being installed.
I do not know how to solve it.
The control apperas correctly on my machine where its is registered.
I give you the steps i go over and maybe anyone knows where i am making a mistake
1) in my release directory with control i build cab file:
cabarc n testCtrl1.cab testCtrl1.ocx pvdt80.ocx testCtrl1.inf
2) my inf file is very simple:
[Add.Code]
testCtrl1.ocx=testCtrl1.ocx
PVDT80.ocx=PVDT80.ocx
[testCtr1.ocx]
file-win32-x86=thiscab
clsid={C54F7CA2-6405-43BD-A189-2471A491142E}
FileVersion=1,0,0,1
[PVDT80.ocx]
file-win32-x86=thiscab
clsid={e9c9692e-f93c-11D1-abb0-0040054fc6fb}
FileVersion=8,0,3,3
3) My html file
<title>New Page
<object classid="CLSID:C54F7CA2-6405-43BD-A189-2471A491142E"
codebase="http://soft2/testCtrl1.cab">
<param name="_Version" value="65536" />
<param name="_ExtentX" value="14970" />
<param name="_ExtentY" value="9440" />
<param name="_StockProps" value="0" />
what is wrong ? Please help
|
|
|
|
|
All of our source is currently written in Borland C which allows the use of #pragma startup 'function_name' which ensures that a function is run when a program is started. Is there an equivilent method in Visual C++?
|
|
|
|
|
Hmmmm.... no - I don't think there is. You can alter the apps entry point, but if I read you correctly I think what you want is a function that gets called before main/WinMain or whatever during runtime init. Best substitute I could think of would be a global static class that performs 'function_name' code in its ctor.
|
|
|
|
|
Create some dummy class with startup code in constructor. Make a global variable of the class - the constructor will be called before main or WinMain.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks for your suggestions. A class that handles the startup/exit code in the constructor/destructor will do nicely.
|
|
|
|
|
i received this linking error:
LINK : warning LNK4098: defaultlib "LIBCD" conflicts with use of other libs; use /NODEFAULTLIB:library
does anyone knwo hwo to resolve this?
thanks in advance
|
|
|
|
|
I find that one thing that can cause this message is the following
(Im using VC++ 5.0):
When you create you Win32 Appwizard application, you are asked whether you you wish to use MFC as a shared DLL or as a static library.
When you create a ".lib" type project you have 3 options...
Using MFC in a static library
Using MFC in a shared DLL
Not using MFC
The ".lib" projects which your Win32 application links in should (in normal situations) be using MFC in the same way as your Win32 app.
For example, I built a ".lib" which used some MFC calls, and I mistakenly selected "Not using MFC" when I created the project, and
it generated exactly the same message as you quote above.
Dave Carkeet,
Santiago, Chile
|
|
|
|
|
Hi all.
If anyone have source code about using MsComm control in program, please send to : hadi_rezaie@hotmail.com
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
When I tried to link MFC libraries statically, I got:
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
Any suggestions????
|
|
|
|
|
Yep - "PRB: LNK2005 Errors When Link C Run-Time Libs Before MFC Libs"
MSKB article ID: Q148652
|
|
|
|
|
hi can somebody tell me how can i put Item checked in a Clistrl into a table
using CStringArray i think.
thanks for your reply.
Somoene who really needs help.
|
|
|
|
|
Please write, what is You goal.
I don't quite understand, why are You trying to use CStringArray with CListCtrl to achieve checkboxes???
Try to look at CCheckBoxList - if You want to have check list box.
For check list control, You have to write Your own or search on the web (there is one in Stingray package). AFAIK there is no such control in MFC.
|
|
|
|
|
I'm sorry if i wasn't clear!!
I had just ask that when i click in a checkbox inside a list control how can i retrieve the item text checked in a table.
I ve heard that u must use CStringArray!!!!!
I hope that i ve exposed my goal clrealy, but I m not sure.
Reply me if u still not understand
bye
|
|
|
|