|
Start -->
All Programs -->
Microsoft Platform SDK <release date> -->
Platform SDK Documentation
|
|
|
|
|
Thanks for the quick reply!
Some times I wonder where I left my brain.
INTP
|
|
|
|
|
John R. Shaw wrote:
Some times I wonder where I left my brain
If you find yours, and mine is hanging around, would you send it home?
It's dinner time.
Software Zen: delete this;
|
|
|
|
|
how to add a number to a string?
can i convert from a string to double and reverse?
e.g
CString (or string) text = "37";
i want to add 4e3 to this value??!!!!!!!
|
|
|
|
|
Lookup the "Data Conversion" functions in the MSDN library (atof).
Basicaly you convert the string to a number add the new value to the old and then use CString::Format() function to replace the string with the new value.
double old = atof(&string);
old += new;
string.Format(_T("%f"),old);
or something simular.
INTP
|
|
|
|
|
Hi, I create this function to convert from double to CString.
var is the number to be converted
ndec Number of digits after decimal point
CString do2CStr(double var,int ndec)<br />
{<br />
int decimal, sign;<br />
char *buffer;<br />
buffer = _fcvt( var, ndec ,&decimal, &sign );<br />
int len=strlen(buffer);<br />
CString number(buffer); <br />
CString valor;<br />
if(sign)
valor="-"+number.Left(decimal)+"."+number.Right(len-decimal);<br />
else<br />
valor=number.Left(decimal)+"."+number.Right(len-decimal);<br />
return valor;<br />
<br />
}
Daniel Cespedes
"There are 10 types of people, those who understand binary and those who do not"
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
Why, doesn't CString::Format work for you ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
I've added a crystal report object to my VC .Net project, but I can't figure out how to display it. Any help? I looked on the msdn and it tells you that it adds the classes for you in C# and VB.Net, but that you have to create them yourself in VC .Net - does anyone have any tips
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I would like to distinguish the editions of windows 2000 in my network.
So far I could not find a way of doing this. It seems there is no function to get the edition of a host in win32 api. NetServerGetinfo in only returning major and minor versions of the remote computer.
How can I get the suite,edition (e.g. win 200 professional, win 200 server etc.)
Orcun Colak
|
|
|
|
|
|
Hi,
I am declaring a std::vector<double> vX. I am filling it up using vX.push_back(aNum).
The problem is i want to put the contents of vX into DP which is defined as
double DP[];
This is because an external routine requires an array that is of the form above.
Any ideas would be appreciated.
Thanks
Kash
|
|
|
|
|
Hi Kash,
IIRC, vector is guaranteed to be continuous (its the only container with the guarantee). So you should be able to return the address of element 0 - &vX[0].
Is vX declared as follows?
std::vector<double> vX;
Please correct me if I am wrong.
Jeff
|
|
|
|
|
I'm new to .Net and am going through a chapter in a book I just bought with an example of an e-mail validation string using a regular expression. The string doesn't work! Does anyone have a proper regex for validating e-mails?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
bdiamond wrote:
The string doesn't work!
Meaning what? It allows an invalid address to pass, or it fails on a valid address?
Here are some examples of e-mail expressions:
http://www.breakingpar.com/bkp/home.nsf/Doc?OpenNavigator&U=87256B280015193F87256C40004CC8C6
http://www.regular-expressions.info/
http://www.codetoad.com/asp_email_reg_exp.asp
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
it allows an invalid e-mail address to pass.
here's the function:
bool CdotnetDlg::ValidEmail(CString strMail)
{
#pragma push_macro("new")
#undef new
CString strPattern = "[\\w]+@[\\w]+.[\\w]{2,3}";
Match* pMatch =Regex::Match(strMail,strPattern);
#pragma pop_macro("new")
return pMatch->Success;
}
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hey all, I have a .h and .lib for an API I would like to use. The only problem is, I need to use it from managed code, therefore, I need to turn it into a dll so I can use DllImport to import the functions. The API was written in C++. What is a quick and easy way to compile this into a dll that I can use?
|
|
|
|
|
what do u mean by "written in C++"?
give an example of a function you want to export.
Don't try it, just do it!
|
|
|
|
|
I want to draw a transparent sprite onto a HDC / HBITMAP from an array.
This is a simplified version of what I have.
Basically I want to draw a sprite (Helicopter) that moves around the screen.
But I can't seem to draw the helicopter without a black block surrounding it.
This is my example sprite - It should draw a diagonal blue and green line.
int yVals[4] = {0, 1, 2, 3};
int xVals[4] = {0, 1, 2, 3};
int colourVals[4] = {0x0000FF00, 0x0000FF00, 0x000000FF, 0x000000FF};
My device handles are:
HDC hSpriteDC;
HDC hMemDC;
HDC hMaskDC;
and a couple others for the background
HBITMAP hSpriteBitmap;
HBITMAP hMemBitmap;
HBITMAP hMaskBitmap;
I call this proc on start up. It creates the HDC's and HBITMAPS. It also draws only the
points that I want to see. I was hoping that it would leave the rest of the "drawing area" transparent. But it didn't.
void initHDC(HDC hDC)
{
hMaskDC = CreateCompatibleDC(hDC);
hMaskBitmap = CreateBitmap(4, 4, 1, 1, NULL);
hSpriteDC = CreateCompatibleDC(hDC);
hSpriteBitmap = CreateCompatibleBitmap(hDC, 4, 4);
hMemDC = CreateCompatibleDC(hDC);
hMemBitmap = CreateCompatibleBitmap(hDC, 4, 4);
SelectObject(hSpriteDC, hSpriteBitmap);
SelectObject(hMemDC, hMemBitmap);
SelectObject(hMaskDC, hMaskBitmap);
int i;
for(i = 0; i < 4; i++)
{
SetPixel(hSpriteDC, xVals[i], yVals[i], COLORREF(colourVals[i]));
SetPixel(hMaskDC, xVals[i], yVals[i], COLORREF(0x00FFFFFF));
}
}
I've also tried inserting
SetBkMode(hSpriteDC, TRANSPARENT)
into my code after the SelectObjects.
I call this Procedure from my OnPaint procedure:
I've tried all sorts of raster operations.
void drawSprite(int x, int y, int dx, int dy)
{
BitBlt(hMemDC, x - 40, y - 40, x + 40, y + 40, hHeliDDC, 0, 0, SRCCOPY);
//I also tried this:
//BitBlt(hMemDC, x - 40, y - 40, x + 40, y + 40, hSpriteDC, 0, 0, SRCCOPY);
//BitBlt(hMemDC, x - 40, y - 40, x + 40, y + 40, hMaskDC, 0, 0, SRCAND);
}
In my OnPaint() procedure, I have:
PAINTSTRUCT ps;
RECT r;
r.top = 0;
r.bottom = 500;
r.left = 0;
r.right = 800;
ps.rcPaint = r;
BeginPaint( hwnd, &ps );
//Draw BackGround
//My background is stored in hBackDC
BitBlt( hMemDC,
ps.rcPaint.left,
ps.rcPaint.top,
ps.rcPaint.right,
ps.rcPaint.bottom,
hBackDC,ps.rcPaint.left,
ps.rcPaint.top,
SRCCOPY );
drawSprite(x, y, dx, dy);
BitBlt(ps.hdc,
ps.rcPaint.left,
ps.rcPaint.top,
ps.rcPaint.right,
ps.rcPaint.bottom,
hMemDC,
ps.rcPaint.left,
ps.rcPaint.top,
SRCCOPY );
EndPaint( hwnd, &ps );
I have tried Seting the pixels in my OnPaint() procedure, but thats too slow.
I hope I've made my problem clear.
Please - any suggestions would be awesome.
|
|
|
|
|
void FooButton::TransparentBlt
(HDC hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
HBITMAP hBitmap,
int nXSrc,
int nYSrc,
COLORREF colorTransparent,
HPALETTE hPal)
{
CDC dc, memDC, maskDC, tempDC;
dc.Attach( hdcDest );
maskDC.CreateCompatibleDC(&dc);
CBitmap maskBitmap;
CBitmap* pOldMemBmp = NULL;
CBitmap* pOldMaskBmp = NULL;
HBITMAP hOldTempBmp = NULL;
memDC.CreateCompatibleDC (&dc);
tempDC.CreateCompatibleDC (&dc);
CBitmap bmpImage;
bmpImage.CreateCompatibleBitmap (&dc, nWidth, nHeight);
pOldMemBmp = memDC.SelectObject (&bmpImage);
if (dc.GetDeviceCaps (RASTERCAPS) & RC_PALETTE && hPal) {
::SelectPalette( dc, hPal, FALSE );
dc.RealizePalette();
::SelectPalette( memDC, hPal, FALSE );
}
hOldTempBmp = (HBITMAP) ::SelectObject (tempDC.m_hDC, hBitmap);
memDC.BitBlt (0, 0, nWidth, nHeight, &tempDC, nXSrc, nYSrc, SRCCOPY);
maskBitmap.CreateBitmap (nWidth, nHeight, 1, 1, NULL);
pOldMaskBmp = maskDC.SelectObject (&maskBitmap);
memDC.SetBkColor (colorTransparent);
maskDC.BitBlt (0, 0, nWidth, nHeight, &memDC, 0, 0, SRCCOPY);
memDC.SetBkColor (RGB (0,0,0));
memDC.SetTextColor (RGB (255,255,255));
memDC.BitBlt (0, 0, nWidth, nHeight, &maskDC, 0, 0, SRCAND);
dc.SetBkColor (RGB (255,255,255));
dc.SetTextColor (RGB (0,0,0));
dc.BitBlt (nXDest, nYDest, nWidth, nHeight, &maskDC, 0, 0, SRCAND);
dc.BitBlt (nXDest, nYDest, nWidth, nHeight, &memDC, 0, 0, SRCPAINT);
if (hOldTempBmp)
::SelectObject (tempDC.m_hDC, hOldTempBmp);
if (pOldMaskBmp)
maskDC.SelectObject (pOldMaskBmp);
if (pOldMemBmp)
memDC.SelectObject (pOldMemBmp);
dc.Detach();
} /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Code copied from CExBitmap.cpp (codeproject article CExBitmap)
CBitmap bmpMask;
if( !bmpMask.CreateBitmap(
bmSrc.bmWidth, bmSrc.bmHeight, 1, 1, NULL) )
{
return FALSE;
}
CBitmap bmpTemp;
if( !bmpTemp.CreateCompatibleBitmap(
pdcDest, bmSrc.bmWidth, bmSrc.bmHeight) )
{
return FALSE;
}
CWorkDC dcTemp(pdcDest, &bmpTemp);
CWorkDC dcMask(pdcDest, &bmpMask);
if( dcTemp.BitBlt(0, 0, bmSrc.bmWidth, bmSrc.bmHeight,
pdcDest, xDest, yDest, SRCCOPY) )
{
dcSrc.SetBkColor(crTrans);
dcMask.BitBlt(0, 0, bmSrc.bmWidth, bmSrc.bmHeight,
&dcSrc, 0,0, SRCCOPY);
dcTemp.BitBlt(0, 0, bmSrc.bmWidth, bmSrc.bmHeight,
&dcSrc, 0, 0, SRCINVERT);
dcTemp.BitBlt(0, 0, bmSrc.bmWidth, bmSrc.bmHeight,
&dcMask, 0, 0, SRCAND);
dcTemp.BitBlt(0, 0, bmSrc.bmWidth, bmSrc.bmHeight,
&dcSrc, 0, 0, SRCINVERT);
pdcDest->BitBlt(xDest, yDest, nWidth, hHeight,
&dcTemp, 0, 0, SRCCOPY);
}
I hope this helps!
INTP
|
|
|
|
|
Is it possible to display a CFormView in a CFrameWnd without using all of the dyncreate stuff? I ask because I don't want to use any of the document stuff - I just want the CFrameWnd to display the CFormView in its client area.
Thanks,
Adam
|
|
|
|
|
Hi,
I am calling the following bit of code from a worker thread via SendMessage to update the user interface in the view:
LRESULT CNetworkMonitoringListView::OnThreadUpdate(WPARAM wParam, LPARAM lParam)
{
CString sResult;
LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_DI_SETITEM;
lvi.iItem = (INT)lParam;
lvi.iSubItem = 0;
lvi.pszText = (LPTSTR)(LPCTSTR)lParam;
GetListCtrl().InsertItem(&lvi);
for (int i = 0; i < 5; i++)
{
lvi.iSubItem = i;
GetDocument()->m_cs.Lock();
sResult = GetDocument()->m_capturedPacket.GetDescription((UINT)lParam, i);
GetDocument()->m_cs.Unlock();
lvi.pszText = (LPTSTR)(LPCTSTR)(sResult);
GetListCtrl().SetItem(&lvi);
}
return 0;
}
The second time the message from the worker thread is processed
GetListCtrl().InsertItem(&lvi)
causes an access violation and fails to add another entry into the CListview, is there anything I can do?
Cheers
Packetlos
|
|
|
|
|
packetlos wrote:
I am calling the following bit of code from a worker thread via SendMessage to update the user interface in the view:
Use PostMessage() instead. Read this article.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Cheers for the link, i have read the article and I am doing what it suggests by using a user defined message to trigger OnThreadUpdate now using PostMessage() and it is still causing access violations. Any other things I should be looking at anybody?
Thanks
|
|
|
|
|