|
Now you should be able to use strncmp() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Good day. I am urgent to find a method to make my static library using (or calling) functions from other static library using Visual C++ 6.0.
I was given a header file and a static library file, for most of the time during application development, I just need to #include the header file and make my project setings link to static library.
But when developing a static library, I found that my project settings cannot link to the static library as Visual C++ 6.0 project settings does't show the link tab.
Is there anyway for me to call the function inside a static library from a static library?
|
|
|
|
|
Hirakawa wrote: I just need to #include the header file and make my project setings link to static library.
Exactly.
Alternatively, you could add
#pragma comment( lib, "libname") to your headerfile.
This is a Microsoft specific way of forcing the linker to include the lib given.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hi George,
Thank you for your reply. If I included #pragma comment(lib, "libname") into my static library file, will the compiler compile everything into one static library?
Update:
I have two static libraries right now (LibraryA.lib and LibraryB.lib). I tried to put #pragma comment(lib, "LibraryA.lib") into LibraryB.h and compile.
The result is the size of LibraryB.lib does not increase...
-- modified at 14:22 Thursday 11th October, 2007
|
|
|
|
|
This will be resolved when you use this library in your final project. In that case, you will need to link against both libraries (otherwise you'll get linking errors).
|
|
|
|
|
Hi Cedric,
Thank you for your reply. Do I need to put #pragma comment(lib, "libname") into both header of static library in order to make the static library link against each other?
|
|
|
|
|
In the project that will use the libraries (which in turn uses the second library), you will need to specify in the project options that the project uses both A.lib and B.lib even if it only uses A.lib directly.
|
|
|
|
|
Thank you. I found the solution already.
For LibraryA.lib and LibraryB.lib,
just #include LibraryA.h in LibraryB.cpp and LibraryB.lib can access to LibraryA.lib provided LibraryA.lib and LibraryB.lib both must include into the project settings of application.
|
|
|
|
|
I need to print a bitmap image (about 2inch X 2inch) at a specific location on a paper but the following code always prints it at the upper left corner. How can I specify the x and y coordinated of the paper? What am I doing wrong? Even if I specify the first 2 parameters of StretchBlt function to my desired location(like 7,7), it prints at the upper left corner of the paper.
Please help!!!
void PrintBitmap(LPCTSTR filename)
{
CPrintDialog printDlg(FALSE);
printDlg.GetDefaults();
CDC dc;
if (!dc.Attach(printDlg.GetPrinterDC()))
{
AfxMessageBox(_T("No printer found!")); return;
}
dc.m_bPrinting = TRUE;
DOCINFO di;
// Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
//di.lpszDocName = filename;
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents
// and store in the m_rectDraw field of a
// CPrintInfo object
CPrintInfo Info;
Info.SetMaxPage(1); // just one page
int maxw = dc.GetDeviceCaps(HORZRES);
int maxh = dc.GetDeviceCaps(VERTRES);
Info.m_rectDraw.SetRect(0, 0, maxw, maxh);
dc.StartPage(); // begin new page
//Info.m_nCurPage = page;
CBitmap bitmap;
// LoadImage does the trick here, it creates a DIB section
// You can also use a resource here
// by using MAKEINTRESOURCE() ... etc.
if(!bitmap.Attach(::LoadImage(::GetModuleHandle(NULL), filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE)))
{
AfxMessageBox(_T("Error loading bitmap!")); return;
}
BITMAP bm;
bitmap.GetBitmap(&bm);
int w = bm.bmWidth;
int h = bm.bmHeight;
// create memory device context
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
memDC.SetMapMode(dc.GetMapMode());
//dc.SetStretchBltMode(FULLTONE);
dc.StretchBlt(7, 7, 2*w, 2*h, &memDC, 0, 0, w, h, SRCCOPY);
// clean up
memDC.SelectObject(pBmp);
bPrintingOK = (dc.EndPage() > 0); // end page
//}
if (bPrintingOK)
dc.EndDoc(); // end a print job
else dc.AbortDoc(); // abort job.
}
|
|
|
|
|
Does it render correctly if using a screen DC?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I did not try using Screen DC. Thanks.
|
|
|
|
|
after the folowing line,
ShilpaPotnis wrote: // clean up
memDC.SelectObject(pBmp);
Use DC.BitBlt(left,top,width,height,memDC,0,0,SRCCOPY);
if this gives an error,
use the following
DC.BitBlt(left,top,width,height,&memDC,0,0,SRCCOPY);
if this also doesnt work, get in touch with me tomorrow i shall refer it in my backups and suggest you.
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
I appreciate your reply. I'll try this. Thanks.
|
|
|
|
|
did you get it?
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
did not get a chance to try it. got tangled in something else. Thanks.
|
|
|
|
|
Adding that line did not work. Still dies the same thing. Thanks.
memDC.SelectObject(pBmp);
dc.BitBlt(5, 5, 2*w, 2*h, &memDC, 0, 0, SRCCOPY);
bPrintingOK = (dc.EndPage() > 0); // end page
//}
|
|
|
|
|
umm...isn't 7,7 at the upper left of the paper?
I don't see any calculations involving inches - pixels=per-inch,
paper dimensions, etc.....do you do that somewhere else?
Is the bitmap already scaled to the printer resolution?
"// LoadImage does the trick here, it creates a DIB section"
Wrong. There's no DIB section involved here.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark! I don't do anything else in my program. Just call the function giving the .bmp filename. also most of the code I've taken from internet so don't understand very well as I am using CDC for very first time. I'll look into it as soon as I get a chance as I got completely tangled in another task.I really appreciate your help! Thanks!
Shilpa.
|
|
|
|
|
Hello everyone,
When do we need to add code,
#define INC_OLE2
in our code? I can not find related information from MSDN.
thanks in advance,
George
|
|
|
|
|
It governs whether ole2.h is included when you #include windows.h . If you include ole2.h yourself you don't need this define.
Also, if NOGDI is not set and INC_OLE1 is not set, ole2.h is included, regardless of the setting of INC_OLE2 , if WIN32_LEAN_AND_MEAN is also not defined.
A few other Windows headers will set INC_OLE2 before including windows.h themselves; whether this has an effect will depend on the order you include the headers, if you do so yourself.
The Windows headers are highly configurable and that configuration is barely documented and very complicated. I generally don't bother defining any configuration options and include windows.h , unless I'm using ATL or MFC in which case I'll include MFC or ATL headers as appropriate.
The aim is to reduce compile times by omitting unused features. However, if you're using precompiled headers it will generally only reduce the time to compile the PCH file.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Thanks Mike!
Are there any additional functions we could use if we use ole2.h other than ole1.h? Are there any compatibility issues? For example, in some situation we could only use ole2.h and can not use ole1.h?
BTW: I am developing COM in Visual Studio 2005.
regards,
George
|
|
|
|
|
Um, OLE 2.0 is now 15 years old! It was introduced with Word for Windows 6.0 in 1993 if I remember correctly. OLE 1.0 was based on Dynamic Data Exchange (DDE). OLE 2.0 is based on COM. There is no reason at all to use OLE 1.0 in a new application.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Thanks for your comment, Mike!
have a good weekend,
George
|
|
|
|
|
Hi,
I'm using VC++6.
In my application I'm using Imgman32.dll for image processing.
I'm cropping a black and white image.
But the cropped image is 16 color.
How do i change it to black and white?
Thanks & Regards,
sanju.
|
|
|
|
|
sanjutvm wrote: I'm cropping a black and white image.
But the cropped image is 16 color.
How do i change it to black and white?
change every pixel image to black , if pixel is not eqal to RGB(255,255,255)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|