Currently I am trying to create a function to implement modularization in the code like below.
[Code 1]
float CBitmapWaterMark::DrawPrintInfoText(HDC hDC)
{
StringFormat* stringFormat = new StringFormat();
// I'm trying to pass a stringFormat object to a member function of a class(CBitmapWaterMark).
stringFormat->SetAlignment(StringAlignmentNear);
stringFormat->SetLineAlignment(StringAlignmentNear);
TestFunction(stringFormat) //help point 1
}
VOID CBitmapWaterMark::TestFunction(StringFormat* stringFormat) // help point 2
{
// implement
}
=> Syntax Error identifier StringFormat
But I don't know how to pass it as a function argument and how to receive it.
There seems to be a problem with StringFormat
which is declared in <gdiplusstringformat.h>
.
This is a minimal complete reproducible example:
#include <windows.h>
#include <gdiplus.h>
#include <gdiplusstringformat.h>
StringFormat fmt;
Error log:
1>C:\Project3 C \main.cpp(5,17): error C4430: missing type specifier - int assumed. Note: C does not support default-int
1>C:\Project3 C \main.cpp(5,14): error C2146: syntax error: missing ';' before identifier 'fmt'
CodePudding user response:
You'll need a using Gdiplus::StringFormat
. The name "StringFormat" is fairly generic, so C has namespaces to prevent name collisions between 2 libraries. GDI puts its names in namespace Gdiplus
.