|
Please check whether the unicode is enabled in your dialog project? You have to define - UNICODE and _UNICODE to preprocessor definitions.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
I am working on this little VC++ 6.0 simple dialog-based application.
No matter whatever I change about the styles etc I only get a combobox
that at launch being clicked shows a drop down cell (one cell) that shows one item with a spin
control on the right corner instead of a full list of items. Of course I can use
the spin control to go through all the items, but it's kind of annoying when
I can simply pick easily from a drop list that shows everything at one time.
how can I solve that problem
Trioum
|
|
|
|
|
Open the resource editor and click on the arrow of the control. You'll be able to modify the size of the drop region instead of the size of the control.
|
|
|
|
|
|
What's the difference between what you are expecting to see and what you are actually seeing?
|
|
|
|
|
why did you delete your question without answering the reply you got ?!
|
|
|
|
|
Thanks for delete your question.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: Thanks for delete your question
what was it about ?!
|
|
|
|
|
I could said where's your question or why did you delete your question
but I said thanks,it was equivocal(thanks doesnt have real mean here ).
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
oh, that was rethorical... I thought you knew much than me
|
|
|
|
|
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
The OP was setting WS_EX_LAYOUT_RTL on a (to be created) window in PreCreateWindow , but he had some (unstated) issue with it - which is why I asked him to describe what he was expecting vs what he saw.
|
|
|
|
|
Thanks for your reply.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hello guys!
Im new in C++ programing, and I want to
get and put same data in my COM.
I dont have problems with basic data types.
My IDL:
[propget, id(FW_DISPID_OFFSET), helpstring("property Offset")] HRESULT Offset([out, retval] short *pVal);
[propput, id(FW_DISPID_OFFSET), helpstring("property Offset")] HRESULT Offset([in] short newVal);
My Cpp:
STDMETHODIMP CYslider::get_Offset(short *pVal)
{
*pVal = m_Offset;
return S_OK;
}
STDMETHODIMP CYslider::put_Offset(short newVal)
{
m_Offset = newVal;
SetDirty(TRUE);
FireViewChange();
return S_OK;
}
So far so good , but now I dont know how to deal with arrays,
I googled a lot and I have found that solution is with VARIANT and safearray
but I dont know how to fill STDMETHODIMP for array.
My IDL:
[propget, id(FW_DISPID_ARRAYTEST), helpstring("property ArrayTest")] HRESULT ArrayTest([out, retval] VARIANT *pVal);
[propput, id(FW_DISPID_ARRAYTEST), helpstring("property ArrayTest")] HRESULT ArrayTest([in] VARIANT newVal);
My Cpp:
STDMETHODIMP CYslider::get_ArrayTest(VARIANT *pVal)
{
????????????????????????????????
return S_OK;
}
STDMETHODIMP CYslider::put_ArrayTest(VARIANT newVal)
{
????????????????????????????????
return S_OK;
}
I will be very happy if somebody could help me, with example, advice...
Bye,
Komofilms
|
|
|
|
|
I haven't worked with COM in quite a few months. The sample code below demonstrates everything you need to know based on your inquiry/statements.
STDMETHODIMP CYslider::get_ArrayTest(VARIANT v)
{
SAFEARRAY *pArrayVal = v.parray;
char HUGEP *pArray = NULL;
HRESULT hr = SafeArrayAccessData(pArrayVal,(void HUGEP * FAR *)&pArray );
SafeArrayUnaccessData(pArrayVal);
return S_OK;
}
HRESULT CYslider::put_ArrayTest(BYTE* data, LONG iLen)
{
VARIANT v;
SAFEARRAY *pArrayVal = NULL;
SAFEARRAYBOUND arrayBound;
CHAR HUGEP *pArray = NULL;
arrayBound.lLbound = 0;
arrayBound.cElements = iLen;
pArrayVal = SafeArrayCreate(VT_UI1, 1, &arrayBound);
if (NULL != pArrayVal)
{
HRESULT hr = SafeArrayAccessData(pArrayVal,(void HUGEP * FAR *)&pArray);
if (SUCCEEDED(hr))
{
memcpy(pArray, data, arrayBound.cElements);
V_VT(&v) = VT_ARRAY | VT_UI1;
V_ARRAY(&v) = pArrayVal;
}
else
{
if (NULL != pArrayVal)
{
SafeArrayDestroy(pArrayVal);
return S_FALSE;
}
}
hr = SUCCEEDED(get_ArrayTest(&v));
SafeArrayUnaccessData(pArrayVal);
}
VariantClear(&v);
return S_OK;
}
Hopefully its enough to get you started. You can tweak it so it works with your application. If you have any questions feel free to ask.
Best Wishes,
-David Delaune
|
|
|
|
|
Here's an example of creating a SAFEARRAY of doubles and returning it through an output parameter (as you have in your get_ArrayTest method):
SAFEARRAYBOUND saBound[2] = { {10, 0}, {5, 0} };
pSA = ::SafeArrayCreate(VT_R8, 2, saBound);
for(int i=0;i<10;++i)
{
for(int j=0;j<5;++j)
{
static long indices[2];
indices[0] = i;
indices[1] = j;
double value = i *5 + j;
::SafeArrayPutElement(pSA, indices, (void*)&value);
}
}
pVal->vt = VT_ARRAY|VT_R8;
V_ARRAY(pVal) = pSA;
Accessing a SAFEARRAY is similar - you use SafeArrayGetElement rather than SafeArrayPutElement and don't need to create or destroy the array.
The vt member of the VARIANT holding the array should define the type of the array as shown, with a VT_type defining the element type, ORed with VT_ARRAY . SafeArrayGetVartype interrogates the SAFEARRAY to get the element type directly.
HTH!!!
|
|
|
|
|
I made it this way....
STDMETHODIMP CYslider::put_VrednostArray(VARIANT newVal)
{
if (!(newVal.vt & VT_ARRAY)) return S_OK;
if (newVal.parray == NULL) return S_OK;
VARTYPE vt = newVal.vt & VT_TYPEMASK;
SAFEARRAY* psaSafeArray = newVal.parray;
SafeArrayLock(psaSafeArray);
long j;
long LBound, HBound;
unsigned long elementsToWrite;
int writeBufferCn;
LBound = psaSafeArray->rgsabound[0].lLbound;
//write minimum of: TotElements, array size
elementsToWrite = m_TotElements;
if (elementsToWrite > 10) { //psaSafeArray->rgsabound[0].cElements) {
elementsToWrite = psaSafeArray->rgsabound[0].cElements;
}
HBound = LBound + elementsToWrite;
VARIANT varValToWriteTableElement;
V_VT(&varValToWriteTableElement) = vt;
writeBufferCn =0;
for(j = LBound; j < HBound; j++)
{
switch( vt )
{
case VT_R4:
SafeArrayGetElement(psaSafeArray, &j, &V_R4(&varValToWriteTableElement));
m_VrednostArray[writeBufferCn++] =(varValToWriteTableElement.fltVal);
break;
default:
break;
}
}
SafeArrayUnlock(psaSafeArray);
FireViewChange();
return S_OK;
}
It Works
Thanks all for help!
|
|
|
|
|
Suppose I've got a variable of type BYTE. It looks something like 10001011 in the memory. Now I want to inverse it so that I get 11010001.
Thank you masters!
|
|
|
|
|
BYTE b = 139;
b = ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
Credit for the discovery of this little neat trick goes to Sean Anderson at stanford university.
Best Wishes,
-David Delaune
|
|
|
|
|
Ok, now explain it
|
|
|
|
|
It works by masking bits/using the AND operator to get the bits in the proper location. It is very beautiful, you can see it working here:
DWORD iTmp =0;
BYTE b = 139;
DWORD c = (b * 0x0802LU);
c &= 0x22110LU;
DWORD d = (b * 0x8020LU);
d &= 0x88440LU;
iTmp = (c | d);
iTmp = iTmp * 0x10101LU;
iTmp >>= 16;
b = iTmp;
Best Wishes,
-David Delaune
|
|
|
|
|
definitely marvelous... with your accordance, may I quote you in my article which talks about bits twiddling ?
|
|
|
|
|
toxcct wrote: may I quote you
Hi toxcct,
Absolutely.
Best Wishes,
-David Delaune
|
|
|
|
|
shame on me, it was already (partially) there
check the article[^], at the Links chapter (down the end) ^^
there it is in the "Reversing bit sequences" chapter of this page[^]...
|
|
|
|