|
It appears that the author has not been good about answering any of them. Bummer.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
I saw a thread where wm_copydata failed due to the nvidia tray-icon app.
MfG
|
|
|
|
|
Ok, but since Dave_ was the one asking the question, you might want to respond to him.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Help, please!
How to access a member in a base class from within an __asm block?
Suppose, we have:
struct s1
{
int a;
};
struct s2 : s1
{
int b;
};
struct s3
{
s2 c;
};
then:
__asm mov eax, [eax]s3.c.b // just fine
but
__asm mov eax, [eax]s3.c.a // ERROR
|
|
|
|
|
Use this instead:
__asm mov eax, [eax]s3.c.b.a
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, this works! Why, however this doesn't:
struct s2 : POINT
{
int b;
};
struct s3
{
int c;
};
__asm mov eax, [eax]s3.c.b.x // 'x' : ambiguous member name in 'second operand'
'x' couldn't be a reserved name, could it??
Is there any way to clarify it to compiler except for defining an offset explicitly, like:
enum { s3s2x = offsetof(s3, s2.x) };
and then
__asm mov eax, [eax + s3s2x]
|
|
|
|
|
How are you expecting to get to 'b' or 'x' through struct s3 since struct s3 and struct s2 know nothing of each other?
__asm mov eax, [eax]s3.c.b.x
^ this dot makes no sense
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Sorry, of course:
struct s2 : POINT
{
int b;
};
struct s3
{
s2 c;
};
__asm mov [eax]s3.c.b.x // error
__asm mov [eax]s3.c.x // error also
And, unfortunately, if s2 has no data members,
that is
struct s2 : POINT
{
void foo();
};
then I wouldn't know how to access POINT::x at all as
__asm mov [eax]s3.c.x
results in error again...
|
|
|
|
|
See if this helps:
int xx = ss3.c.x;
__asm mov eax, [eax][xx]
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Well,
enum
{
s3cx = offsetof(s3, c.x)
};
__asm mov eax, [eax + s3cx]
is better as it requires no additional code, but the point was to access it from within an __asm block with no helpers...
Take a look at this:
struct POINT3
{
int x;
int y;
int z;
};
struct s2 : POINT3
{
int b;
};
struct s3
{
s2 c;
};
Now,
__asm mov eax, [eax]s3.c.b.z // works fine
but
__asm mov eax, [eax]s3.c.b.x // doesn't!!
That's why I asked if 'x' was reserved or smth...
However, if s2 is
struct s2 : POINT3
{
void foo();
};
then
__asm mov eax, [eax]s3.c.z // fails too...
Any suggestions will be greatly appreciated and thanks for your input!
|
|
|
|
|
jk61 wrote:
Now,
__asm mov eax, [eax]s3.c.b.z // works fine
Why this does not yield a compiler error is odd, as 'b' cannot be resolved into anything further as it is an int type. Does that make sense? When you have . and -> notation, it means that the object (i.e., structs and classes) can be broken down even further.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, it would be odd if it was C++ code, but for inline asm it's sort of normal, I suppose.
You suggested that syntax yourself, right? It didn't even cross my mind to try to access 'x' through 'b'. Do you have a ms vc compiler there to try it out?
|
|
|
|
|
jk61 wrote:
You suggested that syntax yourself, right?
Indeed I did. Shame on me!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I give up... That strange access, while compiles ok, results, in fact, in wrong offsets... So, it doesn't work after all and I go with enums
|
|
|
|
|
Hi,
I'm getting the following error whenever I try to build a 'debug' version of any application.
LINK : fatal error LNK1209 program database "C:\test\Debug\test.pdb" differs from previous link; relink or rebuild
Error executing link.exe.
I have tried re-building but it doesn't solve the problem. I even re-installed VC++ but that also didn't help. This is not specific to an application since it occurs even when i build a simple AppWizard application.
Any idea how to solve this problem would be greatly appreciated.
Thanks,
Mel
|
|
|
|
|
Does it happen every time? Can you manually delete the .pdb file and re-build?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Yes, it happens every time and for any application.
Yes, I can delete the .pdb files, but rebuilding doesn't solve the problem.
First time i've experienced this kind of problem in my 5+ years of using VC++
-Mel
|
|
|
|
|
You did reapply the service packs for VS60, I take it...
Steve S
|
|
|
|
|
Yes, I just applied Service Pack 5....but still can't build debug configurations
-Mel
|
|
|
|
|
Hello everyone,
I used the following code to implement the tooltip for a toolbar. But the tooltip won't be displayed when the toolbar window is not active. I know that I can set TTS_ALWAYSTIP to solve this problem. But I don't know how to set it. There is no CToolTipCtrl in my application.
Thanks a lot in advance.
BEGIN_MESSAGE_MAP(CMyView, CView)
...
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
END_MESSAGE_MAP()
void CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();
CEdit* pEdit = new CEdit;
pEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
CRect(10, 10, 100, 100), this, 111);
EnableToolTips(TRUE); // enable tool tips for view
}
//Notification handler
BOOL CMyView::OnToolTipNotify(UINT id, NMHDR *pNMHDR,
LRESULT *pResult)
{
// need to handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
CString strTipText;
UINT nID = pNMHDR->idFrom;
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
}
if (nID != 0) // will be zero on a separator
strTipText.Format("Control ID = %d", nID);
if (pNMHDR->code == TTN_NEEDTEXTA)
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
else
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
*pResult = 0;
return TRUE; // message was handled
}
Thanks
Bin
|
|
|
|
|
I might be misunderstanding the workings of a VARIANT , but I am trying to pack a SAFEARRAY and assign it to my VARIANT . When I place a break point I can see I am getting data into the array but when I try to debug the component in VB I can only get 1 element back which is 0. Does anyone see something wrong with this, this is the first time I have tried using a SAFEARRAY so bare with me. Thanks in advance.
STDMETHODIMP CMoses::GetNumbers(VARIANT *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
HRESULT h;
long lDimension[2];
int startyear, runyear;
startyear = 3;
runyear = 68;
typedef vector<double> collection;
collection numbers;
for(int i = startyear * 12; i < runyear * 12; i += 12)
{
IColumn col(root.Column("nsv_e_0"));
if(col != NULL)
{
CString num;
num.Format("%d", i);
numbers.push_back(col.value(num));
}
}
SAFEARRAYBOUND bounds[1];
SAFEARRAY *psa = NULL;
bounds[0].lLbound = 1;
bounds[0].cElements = numbers.size();
psa = SafeArrayCreate(VT_R8, 1, bounds);
if (psa == NULL) throw ERROR_NOT_ENOUGH_MEMORY;
int j = 0;
vector<double>::iterator it;
for(it = numbers.begin(); it != numbers.end(); it++, j++)
{
lDimension[1] = j;
lDimension[0] = 0;
h = ::SafeArrayPutElement(psa, lDimension, &it);
}
pVal->parray = psa;
return S_OK;
}
- Nick Parker My Blog
|
|
|
|
|
Try
pVal->vt = VT_ARRAY|VT_R8;
just before your 'return S_OK'.
You're setting the VARIANT value, but not it's type.
Steve S
|
|
|
|
|
Steve S wrote:
You're setting the VARIANT value, but not it's type.
Gotcha, that makes sense. Now VB is returning a list of 0's. Not sure why I am not getting the numbers. I threw in a ::AfxMessageBox(...) to check that I am getting a value from the iterator when it is dereferenced, which it is. Am I following the correct syntax by assignment the address of the iterator to the SAFEARRAY ? Thanks again Steve.
[EDIT] I solved the problem, I had the lDimension flip-flopped, thanks again for your help. [/EDIT]
- Nick Parker My Blog
|
|
|
|
|
I am trying to write an application in C++ to implement privacy control. For that I need to know how to read a cookie. If someone knows, please let me know
Thanks,
subbu
|
|
|
|
|
Refer to MSDN articles Q241492 and Q240191.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|