|
I think you'll just need an extra set of brackets...
int viMySetting = ((CMainFrame *)AfxGetMainWnd())->m_iMySetting;
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Try'd it and i finally got passed the compiler warning and had the popup assitance window show my custom members...
That worked so hopefully will the final result...haven't tested that yet...to excited, but soon
Thanx alot
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Does anybody know how to get the number of arguments from a variable length function parameter list? I can't seem to find any documentation anywhere about how to get then number or arguments, without the number of args being a parameter itself.
|
|
|
|
|
You can't. The number (and type) of arguments has to be deduced from one of the non-variable arguments supplied, like, for instance, printf does with its first format argument.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually, you can.
int CountArgs(char* unused, ...)
{
int count = 0;
va_list args;
va_start(args, unused);
for (char* cp = va_arg(args, char*); cp; cp = va_arg(args, char*))
{
count++;
}
va_end(args);
return count;
}
int main()
{
int numArgs = CountArgs("blah", "1", "2", "3", "4");
return 0;
}
You could also use the first variable to indicate how many variables you are passing in.
CountArgs(int numArgs, ...);
Todd Smith
|
|
|
|
|
That the will NOT work reliably. If you look at the code generated, there isn't a NULL pushed onto the stack. Thus, just by luck does this work when it does.
19: int main()
20: {
004010B0 push ebp
004010B1 mov ebp,esp
004010B3 sub esp,44h
004010B6 push ebx
004010B7 push esi
004010B8 push edi
004010B9 lea edi,[ebp-44h]
004010BC mov ecx,11h
004010C1 mov eax,0CCCCCCCCh
004010C6 rep stos dword ptr [edi]
21: int numArgs = CountArgs("blah", "1", "2", "3", "4");
004010C8 push offset string "4" (00422030)
004010CD push offset string "3" (0042202c)
004010D2 push offset string "2" (00422028)
004010D7 push offset string "1" (00422024)
004010DC push offset string "blah" (0042201c)
004010E1 call @ILT+5(CountArgs) (0040100a)
004010E6 add esp,14h
004010E9 mov dword ptr [ebp-4],eax
22: return 0;
004010EC xor eax,eax
23: }
004010EE pop edi
004010EF pop esi
004010F0 pop ebx
004010F1 add esp,44h
004010F4 cmp ebp,esp
004010F6 call __chkesp (00401120)
004010FB mov esp,ebp
004010FD pop ebp
004010FE ret
Specifically in this case, the only reason this works is because EDI was 0.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Tim is correct.
So I would either pass the # args as the first parameter (what I usually do anyways) or if it makes sense require the last parameter to be 0.
Todd Smith
|
|
|
|
|
Yikes!!!!!!!
For a moment I thought I was in the wrong web site
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Is there a way i can change the background color or a read-only CEdit ???
i can't use any classes for a modified Edit control because the edit is already too much embedded in my app i'm not gonna change everything again.
It's a read-only edit so the background is gray by default but i want to make it white.
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
Mike Dunn's C++ FAQ explains how to do it for static controls here. For edit boxes it's the same but handling WM_CTLCOLOREDIT instead of WM_CTLCOLORSTATIC (if you do it the MFC way, though, it's exactly the same for both types of controls).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If the parent dialog gets the WM_CTLCOLOR message for the edit (OnCtlColor) you should be able to identify the control and modify the background brush returned and call SetBkColor and SetTextColor on the dc passed in.
I think there's another way to do it but can't recall right now - check the July 96 MSDN C++ QA for more on this.
later
oops...I mean the July 96 MSJ - but the article should be on the MSDN lib.
|
|
|
|
|
Subject: Stored procedure ADO
Hi,
I working with Stored Procedure with a SQL Database.
I use a procedure for writing to the database 2 paramaters (a STRING and a INTEGER).
My procedure working with the STRING but not when I writing a INTEGER. It is probably in my code at pParam1.
If anyone can help me for this is great.
My code :
_ConnectionPtr pConn("ADODB.Connection");
_ParameterPtr pParam2,pParam1;
CString strFileName = "JK010104";
int iBetacart = 1;
pConn->Open("provider=sqloledb.1;database=ARCHIVES_TVI;server=100.100.100.100;uid=Me;pwd=xxx;network=dbmssocn","","",adConnectUnspecified);
_CommandPtr pCmd("ADODB.Command");
pCmd->ActiveConnection = pConn;
//Cmd->CommandText = "StartFileNum";
pCmd->CommandText = "ResetFileNum";
// pCmd->CommandText = "EndSuccesFileNum";
pCmd->CommandTimeout = 20;
pCmd->CommandType = adCmdStoredProc;
// _RecordsetPtr pRst("ADODB.Recordset");
// pRst = pCmd->Execute(NULL, NULL, adCmdStoredProc);
pParam2 = pCmd->CreateParameter ( _bstr_t ("File_Name"), adVarChar,
adParamInput, strFileName.GetLength (), (_bstr_t) strFileName);
pCmd->Parameters->Append ( pParam2);
Param1 = pCmd->CreateParameter ( _bstr_t ("AutomatNr"), adInteger,
adParamInput, sizeof (int), _variant_t ( long (iBetacart)));
pCmd->Parameters->Append ( pParam1);
_RecordsetPtr pRecordset;
pRecordset.CreateInstance(__uuidof(Recordset));
pRecordset = pCmd->Execute(NULL, NULL, adCmdStoredProc);
youssef
|
|
|
|
|
hi guys,
how to work with SetMenuItemBitmaps() & GetSystemMetrics() with CXMENUCHECK & CYMENUCHECK params ?
example will be great !
thanx
|
|
|
|
|
I am experiencing a problem with time formatting that I'm hoping someone else has encountered and perhaps has some advice.
In a nutshell, with either CTime::Format() or strftime(), the timezone specifier does not work properly -- both %z and %Z return the full name of the time zone. (%z should represent the abbreviated name, e.g. CST and %Z should represent the full name, e.g. Central Standard Time).
In the following example, both would return the exact same string (well, OK, there would be a slight time difference):
CTime time(CTime::GetCurrentTime());
CString cstrDateA = time.Format("%a, %d %b %Y %H:%M:%S %z");
CString cstrDateB = time.Format("%a, %d %b %Y %H:%M:%S %Z");
My development setup:
Windows 2000
Visual Studio 6.0 Enterprise Edition (with latest service pack)
"If ye love wealth better than liberty, the tranquility of servitude better than the animating contest of freedom, go home from us in peace. We ask not your counsels or your arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
--Samuel Adams
|
|
|
|
|
Hello!
If you look at the source, D:\Program\Microsoft Visual Studio\VC98\CRT\SRC\STRFTIME.C, in the function _expandtime then you will see that case('z') and case('Z') is treated the same!
So the doc is wrong ...
For an another perculiar thing try this:
CTime time(CTime::GetCurrentTime());
CString cstrDateA = time.Format("%a, %d %b %Y %H:%M:%S %z");
COleDateTime ttime(COleDateTime::GetCurrentTime());
CString cstrDateB = ttime.Format("%a, %d %b %Y %H:%M:%S %z");
Strange or ??
|
|
|
|
|
Hello everybody!
I've got the following problem: my app uses a WebBrowser-Control, but I don't receive the FileDownload-Event, which would allow to suppress the Download-Dialog.
I'm using the following code:
BEGIN_EVENTSINK_MAP(CMainWnd, CFrameWnd)
ON_EVENT(CMainWnd, IDC_WEBBROWSER, 270 , OnFileDownload, VTS_PBOOL)
END_EVENTSINK_MAP()
void CMainWnd::OnFileDownload(BOOL FAR* Cancel)
{
AfxMessageBox("Why is this message never displayed?");
}
Has anybody got an idea why this doesn't work? Thanks in advance for an evetual answer!
--flo
|
|
|
|
|
Can anyone help me with how to write and read Unicode strings to and from file? I am using wifstream and wofstream and wstring. I can't find any reference material at all about how to do this. Can anyone help or point me at an example or other online resource?
Many thanks
Matthew
|
|
|
|
|
You'll find an interesting article on the subject, written by P.J. Plaugher, here:
http://www.baosys.com/work/cpp/html/17.04/plauger/plauger.htm
|
|
|
|
|
Hi,
I'm writing an MFC-application based on CRichEditDoc/View, where I need to embed files in the document (displayed as icons). Everything works just fine, except for one thing: I can't figure out how to embed an object with a custom icon (or rather, a MetaFilePict = Icon + Label), all I get is the ugly default (such as a Package icon for non-OLE objects).
I know how to properly create the custom metafilepict (it's been tested independently), but when I use COleClientItem's SetIconicMetafile() to assign it to the object, it doesn't work. This is _after_ I've called SetDrawAspect(DVASPECT_ICON), which default COleClientItem implementation resets the icon, but _before_ the view's InsertItem() method. What else do I need to do?
If anyone could give me some hints on what I need to do, I'd really appreciate it!
|
|
|
|
|
How can I add my own button to the title list, or what it is called in English.
A good example is ICQ: The window is a child but the ICQ window has a minimize button too!
So, how to add a button in my window that only has a close button (the 'X' button)!!!!??????????????
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Hello everybody!!!
Please help me with CRectTracker.
I have the Modal Dialog, CRect m_rect and CRectTracker m_tracker variables.
I'm need, that the m_tracker movies inside m_rect ONLY.
As it to make!
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
When yo make the call to start the CRectTracker object tracking, make a call to ClipCursor(Rect) to limit the area the mouse can move in. Once complete call ClipCursor(NULL)
Roger Allen
Sonork 100.10016
|
|
|
|
|
Thank, seems has helped
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
Hi Im not sure exactly what you want. You have your m_rect now do you mean that you want the resize bar inside the rect or that you only want to be able to move the rect to shrink (not enlarge).
If it is the first case use
m_tracker = new CRectTracker(rect,CRectTracker::resizeInside );
Here is how I used it to initilise my CRectTracker to move objects in my dialogs (warning untested code)
CDC* pDC = GetDC();
if (m_tracker)
{
delete m_tracker;
m_tracker = NULL;
}
LPRECT rect = new RECT;
CWnd* wnd = (CWnd*)(GetDlgItem(IDC_EDIT1));
wnd->GetWindowRect(rect) ;
ScreenToClient(rect) ;
m_tracker = new CRectTracker(rect,CRectTracker::dottedLine | CRectTracker::resizeOutside | CRectTracker::hatchedBorder );
m_tracker->Draw(pDC);
delete rect;
rect = NULL;
---
|
|
|
|
|
You move the control inside all dialogue, and it is necessary for me to move the control only in what or parts of the dialogue limited m_rect .
All the same thank, for attention to my problem. If there will be ideas I with pleasure shall listen them!
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|