|
> Would a macro or script be able to handle it?
Yes, I think so - except for the fact that now you have to go through all the decls adding brackets around the function name:
#define MYFUNC(fn_name) BOOL(fn_name)(INT *data)
MYFUNC(somefunction)
{
if (*data)
{
return(TRUE);
}
return(FALSE);
}
I don't have my trusty Stroustrup handy - wonder which compiler is doing the right thing here?
|
|
|
|
|
For a second I thought I was logged in to Celebrity Deathmatch !!!
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.
|
|
|
|
|
Hi,
I'm using Crystal Report 8.0 ...
I need to find a record its Code field is 120 ...
So, first i made the new report with Standard expert ...
Then i choosed all fields that i need ...
But i don't know where i can write SQL !!!
So, please tell me how can i write SQL in my report ...
Thanks,
Hadi Rezaie
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
for hardcoded values you can use Select Expert from the Report menu or the Select page from the Report Expert. or you can change the query at Database/Show SQL Query
setting the where and the order by part at runtime, set the SQLQueryString property of the Report object (RDC) or SQLQuery property (OCX). use must use the exactly same format as Database/Show SQL Query shows
|
|
|
|
|
Hi,
I used of SetSQLQuery, but won't work !!!
m_Crystal.SetSQLQuery("SELECT * FROM PERSON WHERE [CODE] = 1");
What is my wrong ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi.
I'm trying to manage a listbox vertical scroll bar and I have a problem with the function OnVScroll when I drag the scroll box.
In OnVScroll(), when the first parameter nSBCode is SB_THUMBPOSITION or SB_THUMBTRACK, the second parameter nPos is expected to indicate the position of the scroll box. nPos (which is a UINT) can be cast to an int, and then I realized that after 32768, (int) nPos is -32768 ! Then, (int) nPos increases up to 32768 and then -32768 again !!!
How should I proceed to manage the scroll box position when the range of my vertical scroll bar is over 32768 ?
Thanks.
|
|
|
|
|
You should use CWnd::GetScrollInfo instead of parameters passed to WM_VSCROLL. GetScrollInfo supports 32-bit ranges and positions.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I would like to know if i could simply do the difference between 2 COleDateTime variable, if i would know the length of time between them.
m_LenghtOfTime=m_Date2-m_Date1; ?
thanks in advance
gerald
|
|
|
|
|
|
Hi there
Please help me for one of my problem.
I want to generate some random numbers and display them in a edit box with a delay of say 1000 Msec.
For this I have created one dialog based project having one edit box and one start button. On press of start button I am using a for loop to generate 10 random numbers, display them one by one in edit box after a delay of 1000 Msec. To my surprise, only last number is displayed in the edit box.
Other numbers are generated but not displayed in the edit box.
Please suggest how to solve this problem ?
Thanks in Advance.
|
|
|
|
|
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!
|
|
|
|