|
this code can be used to detect the settings...
CDC ScreenDC;
ScreenDC.CreateIC(_T("DISPLAY"), NULL, NULL, NULL);
const int x = ScreenDC.GetDeviceCaps(LOGPIXELSX);
const int y = ScreenDC.GetDeviceCaps(LOGPIXELSY);
if (x == 96 && y == 96)
{
}
else if (x == 120 && y == 120)
{
}
else
{
}
the only real workaround for this problem is to use, depending on the small / large font setting, two different dialog templates.. YUCK...
i don't know any better solution (other than banning the LARGE fonts).. so i would be pleased if anybody knew a better workaround..
Bernhard
"The remarkable thing about my mother is that for thirty years she served us nothing but leftovers. The original meal has never been found." Calvin Trillin
|
|
|
|
|
Is there a function like pow (for doubles) for integers?
I could of course use the pow function, but there just _must_ be some function like it for other datatypes too.
Or is the fastest way to calculate x raised to the power of y by making a loop and multiplying x with itself y times? (faster than pow?)
Sprudling
|
|
|
|
|
This is right out of the MSDN.
//-----------------------------
pow
template<class t="">
complex<t> pow(const complex<t>& x, int y);
template<class t="">
complex<t> pow(const complex<t>& x, const T& y);
template<class t="">
complex<t> pow(const complex<t>& x, const complex<t>& y);
template<class t="">
complex<t> pow(const T& x, const complex<t>& y);
The functions each effectively convert both operands to the return type, then return the converted x to the power y. The branch cut for x is along the negative real axis.
//------------------------------
Vu
vucsuf
|
|
|
|
|
Hi all,
I wanna create array of my class, with dynamic sizes ...
First, i read number from my file:
const int lLoop = getc(fp);
Now, i wanna create my array with lLoop size ...
But i got two errors about my array size !!!
MySoundTemplate *pSound[lLoop];
for(int i = 0; i < lLoop; i++)
pSound[i] = new MySoundTemplate;
How can i slove it ?
Please help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
lLoop is "not constant enough" (it is not known at compile time)
My advice is to use STL vector. It is the easiest way to handle dynamic arrays.
I vote pro drink
|
|
|
|
|
MySoundTemplate *pSound[lLoop];
That is not going to work, because you're trying to create an array of pointers, and you can't - the compiler doesn't know the value of lLoop. You wanted to do this:
MySoundTemplate * pSound = new SoundTemplate[lLoop];
Having said that, I second the other poster - you should use STL vector.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi Christian
MySoundTemplate * pSound = new SoundTemplate[lLoop];
This code won't work ...
I must use of STL vector ...
Thanks ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
MySoundTemplate * pSound = new SoundTemplate[lLoop];
This code won't work ...
Not unless SoundTemplate is derived from MySoundTemplate.
MySoundTemplate * pSound = new MySoundTemplate[lLoop];
will work if MySoundTemplate is a class this line can see.
I must use of STL vector ...
It's better anyhow. You should consider how you will use the list, list may be a better option.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Yes, yes, i know ...
My wrong was in typing ...
I mean:
MySoundTemplate * pSound = new MySoundTemplate[lLoop];
This code won't work, too.
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
This code won't work, too.
There is no reason in the world for this not to work, maybe you should tell me what the errors are ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Just in case you missed the advice, I'd recommend STL vector (or perhaps list), unless the cost of copying a 'MySoundTemplate' objec tis very high (in which case vector can be expensive).
-----------------------
Reg : "Well, what Jesus blatantly fails to appreciate is that it's the meek who are the problem."
|
|
|
|
|
Hello, the codegurus around the world.;)
How about CPtrList or CPtrArray?
I think that these also works.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
How to get RGB data for pixels from bitmap?
For every pixels, and write them into txt file
Not using GetPixels, only from Bitmap
|
|
|
|
|
If you mean a Bitmap (GDI+), then use GetData. The next issue of WDJ will hopefully have an article covering all this.
If you mean CBitmap, you need to create a DIBSection. If you have a bitmap already, then copy it into a DIBSection and access the data that way. If you're creating it, create a DIBSection. This site has several DIBSection wrappers, from memory. It certainly has one.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I have LPBITMAPINFOHEADER structure (it's a frame from avi file),
i can save it as bmp file, but i need array of pixels only,
like this:
12 11 34 ....
32 11 22 ....
.............
22 44 44 ....
and save it as txt file
|
|
|
|
|
If it's a BITMAPINFOHEADER and not a BITMAPINFO, then you don't have a bitmap at all, just a descriptor of what dimensions one should be. Try casting to BITMAPINFO and accessing bmiColors. The first member of BITMAPINFO is BITMAPINFOHEADER, so a cast from BI to BIH will work fine where a BIH is needed.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I tryed, but i don't know how to get every pixels at all (array of RGB)!
If you know how it works, please help me.
I really need it.
Thanks
|
|
|
|
|
It's an array of RGBQUAD, so it's a pointer that contains the values for each pixel as red/green/blue/reserved. Generally Windows bitmaps go bottom to top, left to right, I presume this is the case here.
So to get the values you could do something like:
BITMAPINFO * pBMI = (BITMAPINFO*)MyBitmapInfoHeader;
RGBQUAD * pQuad = pBMI->bmiColors;
for (int x = 0; x < pBMI->bmiHeader.biWidth)
for (int y=0; y < pBMIHeader.biHeight)
{
unsigned char Red = *pQuad;
++pQuad;
unsigned char Green = *pQuad;
++pQuad;
unsigned char Blue = *pQuad;
++pQuad;
++pQuad;
}
That is untested, but you get the idea.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
|
I'm having trouble getting VB to pass in a String into a ATL Object created with VC++ 6.0 -- I dont use MFC. Please help if ya' can! all i really need to know is how to pass in/return... I found some MSDN articles, but they werent using an ATL object. Thanks in advance...
SHABBA!!
|
|
|
|
|
What seems to be the problem? You are using BSTR, right?
|
|
|
|
|
I wasnt using BSTR - I found several "ways to do it" on the net, but I wasnt sure so I didnt want to jump in before I asked.. but I'm using BSTR now and it works - thx!
SHABBA!!
|
|
|
|
|
Hi all,
If I have a global group which has another global
group inside it.For example I have a global group named test and another
global group test1 which is a member of test. I have a user say "A"
which is a member of test1. Now Is there a way I can programmatically find
out whether "A" is a member of test or not. If I try to use the
function "NetUserGetGroups" for "A" it does not return test as one
of the groups to which "A" belongs .
Thanks in advance
|
|
|
|
|
A co-worker sent me the following code so that I could read and write file properties to the file. I pretty much used the open file, open stream in one part to read the properties. I use the open file, open stream to write the properties elsewhere. I don't know why it's not opening the file for writing, and I was hoping someone knew why. At first, I also had Windows Explorer running because I constantly had to retype new comments and authors for test. That's not what's happening. I don't think IPropertySetStorage has a close, so I'm not sure what to do.
int main(int argc, char* argv[])
{
CoInitialize(NULL);
try
{
USES_CONVERSION;
CComPtr<ipropertysetstorage> l_spIPropertySetStorage;
HRESULT hr;
hr = StgOpenStorageEx( L"e:/test/test.spw", STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
STGFMT_ANY, NULL, NULL, NULL, IID_IPropertySetStorage, (void**)&l_spIPropertySetStorage );
if (FAILED(hr)) throw _T("Failed in StgOpenStorageEx");
CComPtr<ipropertystorage> l_spIPropertyStorage;
hr = l_spIPropertySetStorage->Open(FMTID_SummaryInformation,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &l_spIPropertyStorage);
if (FAILED(hr)) throw _T("Failed in l_spIPropertySetStorage->Open");
PROPSPEC l_aPropertySpec[2];
l_aPropertySpec[0].ulKind = PRSPEC_PROPID;
l_aPropertySpec[0].propid = PIDSI_AUTHOR;
l_aPropertySpec[1].ulKind = PRSPEC_PROPID;
l_aPropertySpec[1].propid = PIDSI_COMMENTS;
PROPVARIANT l_aResults[2];
hr = l_spIPropertyStorage->ReadMultiple( 2, l_aPropertySpec, l_aResults );
if (FAILED(hr)) throw _T("Failed to l_spIPropertyStorage->ReadMultiple");
if (S_FALSE == hr) throw _T("Properties not found");
if ( l_aResults[0].vt != VT_LPSTR ) throw _T("vt is not VT_LPSTR");
if ( l_aResults[1].vt != VT_LPSTR ) throw _T("vt is not VT_LPSTR");
CComBSTR l_bstrAuthor = l_aResults[0].pszVal;
CComBSTR l_bstrComment = l_aResults[1].pszVal;
MessageBox(NULL, OLE2T(l_bstrAuthor), _T("Author"), MB_OK);
MessageBox(NULL, OLE2T(l_bstrComment), _T("Comment"), MB_OK);
CComBSTR l_bstrNewAuthor = L"Brad";
CComBSTR l_bstrNewComment = L"Here's my new comments";
// set new values
PROPVARIANT l_aNewValues[2];
l_aNewValues[0].vt = VT_LPSTR;
l_aNewValues[0].pszVal = OLE2A(l_bstrNewAuthor);
l_aNewValues[1].vt = VT_LPSTR;
l_aNewValues[1].pszVal = OLE2A(l_bstrNewComment);
hr = l_spIPropertyStorage->WriteMultiple( 2, l_aPropertySpec, l_aNewValues, NULL );
if (FAILED(hr)) throw _T("Failed in l_spIPropertyStorage->WriteMultiple");
hr = FreePropVariantArray(2, l_aResults);
if (FAILED(hr)) throw _T("Failed in FreePropVariantArray");
}
catch(TCHAR *errMsg)
{
MessageBox(NULL, errMsg, NULL, MB_OK );
}
catch(...)
{
MessageBox(NULL, _T("Unknown Exception"), NULL, MB_OK);
}
CoUninitialize();
return 0;
}
|
|
|
|
|
Is there a easy way to convert a "int" to CString "Days:Hours:Minutes:Seconds";
.. Knowing that the "int" is a total of seconds..
Thanks,
Rob
|
|
|
|