|
After m_yourEdit.SetWindowText you should call m_yourEdit.UpdateWindow().
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Anyone managed to make GDI+ work fro the June CD ? After figuring out places they have changed function prototypes, I am still left with the following errors:
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(32) : error C2065: 'ULONG_PTR' : undeclared identifier
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(32) : error C2065: 'token' : undeclared identifier
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(32) : error C2165: 'left-side modifier' : cannot modify pointers to data
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(32) : error C2071: 'NotificationHookProc' : illegal storage class
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(33) : error C2146: syntax error : missing ')' before identifier 'token'
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(33) : error C2165: 'left-side modifier' : cannot modify pointers to data
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(33) : error C2071: 'NotificationUnhookProc' : illegal storage class
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(33) : error C2059: syntax error : ')'
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(86) : error C2059: syntax error : 'const'
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(95) : error C2146: syntax error : missing ')' before identifier 'token'
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(95) : warning C4229: anachronism used : modifiers on data are ignored
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(95) : error C2182: 'GdiplusShutdown' : illegal use of type 'void'
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE\PRERELEASE\GdiplusInit.h(95) : error C2059: syntax error : ')'
Error executing cl.exe.
My code does not call the functions in GDIPlusInit ( it's a COM component that assumes GDI+ has been started ). It works at work with the old SDK, but I did a full install of the new one and apparently it does not know what a ULONG_PTR is, and if I #define it myself all compiles fine. This should not be, surely ?
Also, I've searched and there is nonew dll ( at least not on my hard drive after a full install ). Is there no new dll ? How is this possible ? Where is it hidden ?
Thanks to anyone with constructive suggestions ;0)
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
ULONG_PTR is #defined in basetsd.h
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
Dear all
How can I get the MAC-adress from a host computer?
Thanks
|
|
|
|
|
Here are two calls, both fail at times.
The first uses the guid geenrated on a machine so it fails on W2K and ME machines as they no longer have the strait MAC Address as part of the guid.
The second is more complicated code and will fail if the LAN adapter is locked (or not there) (which would be the case if you had a server running).
For a basic client machine I have found it works ok.
CString GetTheNetworkCardID()
{
// This Fails on Win 2K and Win ME OS's
CString ID;
// Note:
// This uses RPC calls
// Requires #include "rpc.h"
// to define uuidtostring calls Requires link with rpcrt4.lib
// End Note
unsigned char *idName;
UUID MyUID;
UuidCreate(&MyUID);
MyUID.Data1=NULL;
MyUID.Data2=NULL;
MyUID.Data3=NULL;
UuidToString( &MyUID, &idName);
ID = idName;
return ID.Right(12);
}
// requires Netapi32.lib for linking
CString GetTheMacAddress(int adapter_num)
{
CString mac_addr;
TRY // if the request has an invalid port it fails. Need to look for option for error test
{
// Reset the LAN adapter so that we can begin querying it
NCB Ncb;
memset(&Ncb, 0, sizeof(Ncb));
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = adapter_num;
if (Netbios(&Ncb) != NRC_GOODRET)
{
mac_addr = "BAD (NCBRESET): ";
mac_addr += Ncb.ncb_retcode;
goto fail_mac;
}
// Prepare to get the adapter status block
memset(&Ncb,(char)0,sizeof(Ncb));
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = adapter_num;
strcpy((char *) Ncb.ncb_callname, "*");
struct ASTAT
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff[30];
} Adapter;
memset(&Adapter,(char)0,sizeof(Adapter));
Ncb.ncb_buffer = (unsigned char *)&Adapter;
Ncb.ncb_length = sizeof(Adapter);
// Get the adapter's info and, if this works, return it in standard,
// colon-delimited form.
if (Netbios(&Ncb) == 0)
{
mac_addr.Format("%02X%02X%02X%02X%02X%02X",
int (Adapter.adapt.adapter_address[0]),
int (Adapter.adapt.adapter_address[1]),
int (Adapter.adapt.adapter_address[2]),
int (Adapter.adapt.adapter_address[3]),
int (Adapter.adapt.adapter_address[4]),
int (Adapter.adapt.adapter_address[5]));
}
else
{
mac_addr = "BAD (NCBASTAT): ";
mac_addr += Ncb.ncb_retcode;
}
}
CATCH_ALL(e)
{
mac_addr = "BAD";
}
END_CATCH_ALL
fail_mac:
if(mac_addr.Left(3).Compare("BAD")==0)
{
mac_addr = GetTheComputerName();
mac_addr+="abababababab";
mac_addr = mac_addr.Left(12);
}
else if(mac_addr.Left(12).Compare("000000000000")==0)
{
mac_addr = GetTheComputerName();
mac_addr+="abababababab";
mac_addr = mac_addr.Left(12);
}
return mac_addr;
}
|
|
|
|
|
Back to my old chestnut of printing from a dialog based app.
Got the text printing on a page using CDC::TextOut(), after setting the logical units to physical units using CDC::SetMapMode.
What I want to be able to do is select the Font I am using to print, and determine the dimensions of a given string in that font using the same units so I can determine how many lines will fit on a page as well as a line. I can't find any of these functions in the online help, the MDI/SDI printing code generated doesn't help and I can't find any demos lying around the Internet on how to do this correctly from Dialogs.
Can somebody help with an answer or a gun (I'm in Australia, if you read the thread in the Lounge earlier in the week you would understand.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Check out GetTextExtentPoint32() API function. I've a strong feeling this is what you need.
-Shanker.
|
|
|
|
|
I haven't had chance to look at checking the text extent, but I think Shanker has helped there. The following example shows printing a title in centred, bold, 16 point, Times New Roman and then some other text left-aligned, 8 point, Courier New. The example is the message handler for a Print button on a dialog.
Hopefully this should help with your font problem
void CPrintTestDlg::OnButtonPrint()
{
CPrintDialog dlg (FALSE);
if (IDOK != dlg.DoModal())
return;
CWaitCursor wait;
HDC printerDC = dlg.CreatePrinterDC();
CDC dc;
dc.Attach( printerDC );
CPoint pt( GetDeviceCaps(dc.m_hDC, HORZRES),
GetDeviceCaps(dc.m_hDC, VERTRES) );
dc.DPtoLP( &pt );
CRect rectPage( 0, 0, pt.x, pt.y );
CString strTitle = "Document Title";
DOCINFO docInfo;
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = strTitle;
docInfo.lpszOutput = 0;
docInfo.lpszDatatype = 0;
dc.StartDoc( &docInfo );
dc.StartPage( );
int currentY = 0;
LOGFONT* pLogFont = new LOGFONT;
pLogFont->lfCharSet = ANSI_CHARSET;
pLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
pLogFont->lfEscapement = 0;
CString strFaceName = "Times New Roman";
lstrcpy (pLogFont->lfFaceName, strFaceName);
pLogFont->lfHeight = -MulDiv (16, GetDeviceCaps (dc.m_hDC, LOGPIXELSY), 72);
pLogFont->lfItalic = FALSE;
pLogFont->lfOrientation = 0;
pLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
pLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
pLogFont->lfQuality = DEFAULT_QUALITY;
pLogFont->lfStrikeOut = FALSE;
pLogFont->lfUnderline = TRUE;
pLogFont->lfWeight = FW_BOLD;
pLogFont->lfWidth = 0;
CFont* pFont = new CFont;
pFont->CreateFontIndirect( pLogFont );
CFont* pOldFont = dc.SelectObject( pFont );
dc.SetTextAlign( TA_CENTER );
dc.TextOut( rectPage.Width() / 2, rectPage.top, strTitle );
currentY += abs (pLogFont->lfHeight);
dc.SelectObject (pOldFont);
pFont->DeleteObject ();
delete pFont;
pFont = new CFont;
pLogFont->lfHeight = -MulDiv (8, GetDeviceCaps (dc.m_hDC, LOGPIXELSY), 72);
pLogFont->lfUnderline = FALSE;
pLogFont->lfWeight = FW_NORMAL;
strFaceName = "Courier New";
lstrcpy (pLogFont->lfFaceName, strFaceName);
pFont->CreateFontIndirect( pLogFont );
pOldFont = dc.SelectObject( pFont );
currentY += abs (pLogFont->lfHeight);
dc.SetTextAlign( TA_LEFT );
CString strText = "Some text to output.";
dc.TextOut (0, currentY, strText);
dc.SelectObject( ::GetStockObject(NULL_BRUSH) );
dc.Rectangle( rectPage );
dc.EndPage();
dc.EndDoc();
delete pLogFont;
delete pFont;
dc.Detach();
DeleteDC( printerDC );
}
If you need any more help let me know and I'll see what I can do.
Derek.
|
|
|
|
|
How to disable a control(let's say combo)?
|
|
|
|
|
In MFC:
combo1.EnableWindow(FALSE);
from memory the Windows API is something like:
EnableWindow(hCombo, FALSE); //hCombo is a window handle
hope this helps.
Matt
------
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
Has anyone been able to use the Xalan.transform call. I have been going around in circles for a couple of days and getting nowhere.
The supplied sample uses an ostrstream variable for the third argument and that will not compile for me. When I convert the third argument to an XSLTResultTarget (various attempts) if compiles but then crashes in the function. Any guidance is very much appreciated.
// Begin My Code which compiles but crashes on the .transform call
// Call the static initializer for Xerces.
XMLPlatformUtils::Initialize();
// Initialize Xalan.
XalanTransformer::initialize();
// Create a XalanTransformer.
XalanTransformer theXalanTransformer;
CString theXMLFileName = "MyTest.xml";
CString theXSLFileName = "MyText.xsl";
XalanDOMString theOutput;
XSLTResultTarget theTarget(theOutput);
// Do the transform.
int theResult = 0;
theResult = theXalanTransformer.transform((LPCSTR)theXMLFileName, (LPCSTR)theXSLFileName, theTarget);
// Terminate Xalan.
XalanTransformer::terminate();
// Call the static terminator for Xerces.
XMLPlatformUtils::Terminate();
// End My Code
//Sample code – which will not compile
ostrstream theOutput;
// Do the transform.
theResult = theXalanTransformer.transform(theXMLFileName, theXSLFileName, theOutput);
// End Sample Code
|
|
|
|
|
Just to document the initial problem.
The error was the version that would not compile was not using the same include for the declaration of ostrstream that the Xalan build had used. Rebuilding the entire set (Xerces, Xalan, and my sample) fixed that problem.
Now however I find that the Xalan code will only work for me in a console application. The same code copied into a function in a Dialog application always returns an error (can not parse XML file). The file is the same one processes in the console app.
If any one has any samples of using the Xalan transformation code in a windows app I woud appreciate seeing it.
Thanks Mike
Michael A Barnhart
mabtech@swbell.net
|
|
|
|
|
Here's a test for all you C/C++ programmers: anything strange in the following code fragment? (Try not to compile it, okay? Just see if you can spot anything strange!)
char ch;
for (ch = 0;ch <= 255;ch++)
std::cout << ch;
|
|
|
|
|
There is no opening and closing brackets for the cout instruction?
This works with the microsoft compiler but not with C++ Builder.
(Am I wrong? - I really didn't cheat)
|
|
|
|
|
oops, wrong answer, Frederick! See the other posts!
|
|
|
|
|
Besides the first 31 characters containing control and unprintable characters, I would say the problem would be that 255 would never be reached. char can contain values -128 through to 127. As soon as the eighth bit was filled it would become a negative number.
So how did I go?
Am I as good as I tell my wife I am or what !!!
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Even with unsigned char, you would have trouble because the loop condition is for i <= 255, so even an unsigned char would roll over to 0 without terminating the loop.
|
|
|
|
|
Not true. unsigned char can hold a value of 255. Formula is 2n -1 (where n is the number of bits in the data type)for unsigned values. In this case it is 28 - 1 = 255.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Of course unsigned char can hold 255, but to terminate this loop you need 256, look again on condition:
ch<=255;
Do you feel that you still good?
|
|
|
|
|
Bingo! I'd say your wife is lucky. On the other hand, you could be a nerd...
|
|
|
|
|
Dear All
How efficient is this editor to build a customized setup file making use of the windows installer.
regards
Sankar
|
|
|
|
|
Orca is not the tool to use for creating Windows Installer packages. You need something like Installshiled or Wise. Orca can be used to view and modify an existing package though.
|
|
|
|
|
Has anyone figured out how Microsoft (MFC) gets away with storing a pointer to a function with the thiscall calling convention (meaning it pushes an implicit this before its normal parameters)?
|
|
|
|
|
There's nothing magical about it, if I understand your question. When you call the function thru the function pointer, you still need an object to provide the this pointer.
CWnd wnd = ....;
BOOL (CWnd::*pFunc)(int) = CWnd::ShowWindow;
(wnd.*pFunc)( SW_SHOW ); In that example, wnd provides this .
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
That did the trick. It makes sense too...I was just under the impression you couldn't declare a function pointer with the CWnd:: attached to it. Probably remnants of someone telling me "Oh you want to do what?? you cant do that!" Thanks a bunch
|
|
|
|