|
|
like this
<br />
CString FileName=_T("Ping");<br />
CString strParam=_T("127.0.0.1");<br />
<br />
ShellExecute(NULL,_T("open"), FileName,strParam,NULL,SW_SHOW);<br />
<br />
|
|
|
|
|
And If I want to open a pdf on folder?
I want to attach to my program a Help manual on pdf.
|
|
|
|
|
Just use ShellExecute like this:
ShellExecute(NULL, _T("open"), "C:\\MyFolder\\MyPdf.pdf", "", "", SW_SHOW);
RicoH
Don't think you are, know you are...
custom hardware & software - olloc.be
-- modified at 10:48 Friday 12th May, 2006
|
|
|
|
|
|
i am trying to use some activex controls that came with vc++ 6, but it wont let me insert any of them into my dialog, keeps saying connot be instantiated, or i need a design time license. is there anyway around all that?
|
|
|
|
|
I'm trying to create an 8 bit DIB image with a grayscale palette
I create the image like so
char* bmpStruct = new char[ sizeof(BITMAPINFO) + (sizeof(RGBQUAD) * 256) ];
bmpInfo_ = (BITMAPINFO*)bmpStruct;
bmpInfo->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmpInfo->bmiHeader.biWidth = width;
bmpInfo->bmiHeader.biHeight = -height;
bmpInfo->bmiHeader.biPlanes = 1;
bmpInfo->bmiHeader.biBitCount = 8;
bmpInfo->bmiHeader.biCompression = BI_RGB;
bmpInfo->bmiHeader.biSizeImage = height * width;
I then create the rgb pal colors:
RGBQUAD* colors = &bmpInfo->bmiColors[0];
for ( int i=0;i<256;i++ ) {
colors->rgbBlue = i;
colors->rgbGreen = i;
colors->rgbRed = i;
colors->rgbReserved = 0;
colors ++;
}
A call to CreateDIBSection() then create the bitmap. This works fine. The problem arises when I try and blt the image to an HDC.
As I understand it, I need to create a palette, select it into the dest DC via a call to SelectPalette(), then call RealizePalette, and then to draw the image I call SetDIBitsToDevice(). I do all this, and the image does get drawn, however the colors it uses don't seem to reflect what I put into the palette.
I create the palette with this code:
unsigned char* tmp = new unsigned char[ sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 255) ];
LOGPALETTE* pal = (LOGPALETTE*)tmp;
pal->palNumEntries = 256;
pal->palVersion = 0x300;
PALETTEENTRY* entry = &pal->palPalEntry[0];
for (int i=0;i<pal->palNumEntries-1;i++ ) {
entry->peRed = bmpInfo.bmiColors[i].rgbRed;
entry->peGreen = bmpInfo.bmiColors[i].rgbGreen;
entry->peBlue = bmpInfo.bmiColors[i].rgbBlue;
entry->peFlags = 0;
entry ++;
}
HPALETTE palette_ = ::CreatePalette( pal );
This should give me a palette with a smooth gradient from black to white (0 to 255).
When I alter the bits of a the image (I create an image of 256 pix wide and 100 tall) so that the bits of each line range from 0 to 255, I expect to see this smooth gradient, but instead I see a gradient from 0 to 127! Assigning a pixel the value of 255 instead displays an RGB value of 127,127,127. Something stupid is going on, but I just don't get it.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hey, it helps to use the right parameters!!
Note to self: do NOT call SetDIBitsToDevice() using DIB_PAL_COLORS, which is kind of what I would expect to use, nope, instead use DIB_RGB_COLORS, and everything is fine! Woot!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Hi,
I'm looking for a way to convert from a unicode CString (project is in UNICODE) to a Base64 string, so I can send it via XML to a web service.
Not much luck trying to use the ATL functions... maybe someone can see what i'm doing wrong or has a sample that works ? thanks !!!
CString csTest = _T("test123");
DWORD dwLen = csTest.GetLength();
int nDestLen = Base64EncodeGetRequiredLength(dwLen);
LPSTR strEncoded = new CHAR[nDestLen];
Base64Encode((const BYTE*)csTest.AllocSysString(), csTest.GetLength(), strEncoded, &nDestLen);
//strEncoded contains: "dABlAHMAdA==ÍÍýýýýÝÝÝÝÝÝ " after conversion
LPSTR strDecoded = NULL;
int iLen = 0;
Base64Decode(strEncoded, nDestLen, NULL, &iLen);
strDecoded = new CHAR[iLen]; //iLen is 7 at this point
Base64Decode(strEncoded, nDestLen, (BYTE*)strDecoded, &iLen);
//strDecoded contains: "t" after conversion, not the original "test123"
|
|
|
|
|
Not sure what is the problem with your code but this works
CString s(_T("Hello world"));
CString sout;
int nDestLen = Base64EncodeGetRequiredLength( s.GetLength());
int outLen = s.GetLength();
LPSTR encoded = new CHAR[ nDestLen];
ZeroMemory( encoded, sizeof(CHAR) * nDestLen);
LPCSTR inPtr = s;
Base64Encode((const BYTE*)inPtr, s.GetLength(), encoded, &nDestLen);
LPSTR decoded = new CHAR[ outLen + 1];
ZeroMemory( decoded, sizeof(CHAR) * (outLen+1));
Base64Decode( encoded, nDestLen, (BYTE *)decoded, &outLen);
sout = decoded;
std::cout << (LPCTSTR)sout << std::endl;
delete [] encoded;
delete [] decoded;
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Are you compiling this in a Multibyte project ? then it works.... but if I try to compile it in a UNICODE project, I get this error:
error C2440: 'initializing' : cannot convert from 'CString' to 'LPCSTR'
on the line where you set LPCSTR inPtr = s;
since s, the CString, is LPCTSTR.
I ended up using something like this, which converts the unicode to LPSTR first, but not sure if it's the best... (also on my Decode function, I needed to convert the decoded string from MultiByte back to WCHAR to get it to match the original:
//since we're unicode, first let's convert to UTF-8
int iRes = WideCharToMultiByte(CP_UTF8, NULL, csSource, csSource.GetLength()*sizeof(TCHAR), NULL, 0, NULL, NULL);
LPSTR szMultiByte = new CHAR[iRes];
iRes = WideCharToMultiByte(CP_UTF8, NULL, csSource, csSource.GetLength()*sizeof(TCHAR), szMultiByte, iRes, NULL, NULL);
//convert to b64
int iDestLen = Base64EncodeGetRequiredLength(iRes);
LPSTR szDest = new CHAR[iDestLen];
Base64Encode((BYTE*)szMultiByte, iRes, szDest, &iDestLen, NULL);
CString csDest(szDest);
delete szMultiByte;
delete szDest;
return csDest;
|
|
|
|
|
So you have a solution now or no?
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Yes, it seems ok now, thanks for the feedback.
|
|
|
|
|
|
|
Sachin .S .Potdar wrote: am looking out for a code for Encryption and Decryption of data using RC4 algorithm in VC+
try HERE[^]
Sachin .S .Potdar wrote: Student persuing Masters in Computer Application.
Where?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hi all,
I have problem in msflexgrid, its scrolls don't take the theme of xp.
please answer me..
best regards
-- modified at 13:33 Thursday 11th May, 2006
|
|
|
|
|
How do I get notification that a button is being held down.
In my app I want a single click to advance to the next record and I want a click and hold to advance records slowly.
I was going to set a Timer in the LBUTTONDOWN while tracking in the rectangle of the button but the button eats the LBUTTONDOWN notification for the dialog.
How do I get a button to pass on the LButtonDown notification to its parent dialog? (I tried setting the Notify flag but it didn't change anything)
Thanks in advance.
Dave
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Dave
|
|
|
|
|
|
Hi All
I have a window which auto-refreshes every 5 minutes. Now I want to,
1. Once window gets auto-refreshed I need to capture the window message. How should I do that, probably by capturing WM_REFRESH in a windows service or so?
2. Once auto-refresh message has been captured, I need to check whether window contents had been changed from previous display. How can i do that?
Many thanks for your inputs
Ramesh
|
|
|
|
|
Each time the window refreshes, you have to capture it into a bitmap then compare the bitmap with the last screen capture. So to capture the screen:
HDC hMemDC;
HBITMAP hBitmap;
HBITMAP hBitmapOld;
BITMAPINFO bmi;
LPBYTE data;
int width, int height;
RECT rc;
GetWindowRect( hwnd, &rc );
width = rc.right - rc.left;
height = rc.bottom - rc.top;
hMemDC = CreateCompatibleDC( hDC );
hBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS, (void**)&data, NULL, NULL );
hBitmapOld = (HBITMAP)SelectObject( hMemDC, hBitmap );
if( hBitmap )
{
BitBlt( hMemDC, 0, 0, width, height, hDC, 0, 0, SRCCOPY );
SelectObject( hMemDC, hBitmapOld );
}
At this point your buffer given by "data" will have the pixel contents from the screen. You will need to load the previous bitmap and compare pixels. To load a previous bitmap you can use the LoadBitmap and GetBitmapBits functions.
I hope this helps.
Deus caritas est
|
|
|
|
|
if (st_x >= 0 && st_y >= 0)
if (st_x <= dForme.Width && st_y <= dForme.Height)
//change button position
button2.SetBounds(st_x, st_y, button2.Width, button2.Height);
else
{
textBox2.Text = st_x.ToString();
textBox3.Text = st_y.ToString();
}
visual c++ position of button little code That is a little code for visual c++. That code change position of button.
is that ok ?
-- modified at 11:00 Thursday 11th May, 2006
|
|
|
|
|
|
I think yes
I see Control.SetBounds Method in (.NET Framework Class Library)
|
|
|
|
|
|