|
|
use the function setwindowforground
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Does anyone have any ideas on how to make a dialog box be only draggable within its parents window...ie....if someone tried to drag the dialog passed the borders of the main application, it wouldnt let them. im trying to go for a toolbox type style....thanks.
KMaz
|
|
|
|
|
Hi there.
Does anyone know how to treat a command line argument as a single argument, instead of the default mechanism of providing space delimited tokens, as in the standard argn/v implementation.
James.
|
|
|
|
|
How about the GetCommandLine() API call?
|
|
|
|
|
Thanks.
Will check that out.
James
|
|
|
|
|
I have read a few of the dll tutorials on this site, but I'm still having a problem. I have a dll that does a global hook that I would like to use to reroute the message to another application. I also have a PreTranslateMessage function overridden in my Ceditview class that works fine with its MSG* parameter. Most of the examples I've seen use the user-defined messages to reroute the messages to a user's app, I'd like to reroute the entire message.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hello i have standart MDI aplication generated by AppWizard and my task is to draw someting(bitmap) on main frame window. Something must be visible (a logo) on a frame window (in this gray area) when there aren't opened any views or views aren't maximazed. I will be greatefull for any help.
|
|
|
|
|
Hi All,
I use the code below to load a bitmap file to my program.
void CStartupDlg::LoadPictureFile(HDC hdc, LPCTSTR szFile, CBitmap *pBitmap, CSize &mSize)
{
// open file
HANDLE hFile = CreateFile(szFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
_ASSERTE(INVALID_HANDLE_VALUE != hFile);
// get file size
DWORD dwFileSize = GetFileSize(hFile, NULL);
_ASSERTE(-1 != dwFileSize);
LPVOID pvData = NULL;
// alloc memory based on file size
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
_ASSERTE(NULL != hGlobal);
pvData = GlobalLock(hGlobal);
_ASSERTE(NULL != pvData);
DWORD dwBytesRead = 0;
// read file and store in global memory
BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
_ASSERTE(FALSE != bRead);
GlobalUnlock(hGlobal);
CloseHandle(hFile);
// create IStream* from global memory
LPSTREAM pstm;
HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pstm);
_ASSERTE(SUCCEEDED(hr) && pstm);
// Create IPicture from image file
hr = ::OleLoadPicture(pstm, dwFileSize, FALSE, IID_IPicture, (LPVOID *)&gpPicture); <==== It said the memory allocated here is not released.
_ASSERTE(SUCCEEDED(hr) && gpPicture);
pstm->Release();
...........................................................................
gpPicture->Release();
}
After I use "Rational Purify" to check memory leak, it reports a memory leak happened.
Could you tell me what I shd release?
Thanks in advance
Vincent
|
|
|
|
|
vincentye wrote:
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
Where is the matching call to GlobalFree() ? See here for an example that complements the Loadpic.exe example from MSDN. Here is a class example.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thx for your reply.
I did try GlobalFree(hGlobal), follow the code of "pstm->Release()", but Purity told me I am trying to release an unallocated memory. Where shd I put the GlobalFree() function in this case? If I put it before pstm->Release(), Purify told me this message : "[W] PAR: Global/LocalLock(0x571001c) arg #1 (hMem) attempt to lock handle that is on pending free queue. {1 occurrence}"
Thx again
Vincent
|
|
|
|
|
Hi.. I'm total new to GDI+
I dont' even know what it is exactly yet. Before I go seeking more information to find out whether I can use GDI+ to get the images (jpg, tiff, gif) properties, I think I better ask gurus first so if it is not the right one for me, I wont' waste my time reading and searching more information to find out GDI+ can solve my problem.
Could I use GDI+ to get the images (tiff, jpg, or gif) information such as, resolution, image size, color/ black and white etc ?
If GDI+ is the right class to use it. How to use it please.
Thank You
|
|
|
|
|
Hello,
I have RGB data of a bitmap in a buffer. And i want to get a HBitmap from this data so that i can select it in MEmory and then blit it to screen. Can anyone help???
Omar Alvi
|
|
|
|
|
First, a simple question: do you have any other method of transfering the bitmap data, other than raw RGB ? Such as a bitmap file ? Creating bitmaps from raw data is a painful process, and very sensitive to errors..
But, let's get to it. The following check-up list will create somekind of a bitmap for you and blit it to the screen. It might or might not look correct.
1. Create a memory device context that is compatible with the display or the window you wish to blit to.
2. Create a bitmap that is compatible with this DC, specifying the width and height as you do. The width and height are dependant on the size of the color data you have. They MUST match.
3. Select the bitmap into the device context.
4. By using SetPixel , set the color of each pixel in the memory DC. You get the colors from the data at the buffer.
5. Blit from the memory device context into the target DC.
After this, the target DC contains a representation of the bitmap data in memory. The colors may be wrong, and if so, you need to determine the palette that was first used to create the data in the memory. This is next to an impossible task (probably), so I can't advise you further in that.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Amm well actually i guess i dont have any other method of trasfering bitmap other than raw RGB.
Actually i have a bitmap lets say image.bmp file i can use LoadImage() to get the hBitmap handle to it which can then easily selected in memory and then blitted to screen...
But the problem is that i want to read an encrypted bmp file(whcih i encrypt myself) and then decrypt it and afterwards i want to display it in GDI so i need to get the hBitmap handle....i guess the only way is to make the bitmap from raw rgb data..any bright ideas ???
Omar Alvi
|
|
|
|
|
If this is the case, then you should divide your process into a two-fold part: the first part consists of the encryption/decryption methods. Both of these functions work on plain files only.
An example: you have a non-encrypted bitmap file. You then give this file's name into the encryption function, that uses the algorithm you determine to write a NEW file, that contains encrypted data. Now, you have an encrypted file.
Next you can give this file as an input parameter to the decryption method, that decrypts the file and WRITES the non-encrypted bitmap file to disk again. When the file write is complete, you can give the file name as a parameter to LoadImage that will then load the bitmap image from disk into memory and give you a HBITMAP handle to it. When the loading is complete, you can delete the non-encrypted bitmap file, leaving only the encrypted one to the disk.
Last alternative is to create the bitmap from scratch. Doing it requires you to fill BITMAPV5HEADER , BITMAPINFO structures, then call CreateDIBitmap to create a device-independent bitmap. An alternative way is to use CreateDIBSection, which will create the DIB and give you a pointer to the location of the DIB bits. You can then use the pointer to write the DIB data directly.
There seems to be one example available here on Code Project. See here.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hey everyone,
I guess this is a pretty generic question, but I figure what the heck. I am looking to work on some outlook settings through a program. I have some users here at work that dont really want to change there outlook settings when they go from the office to home. Does anyone know what file (if there is any) I would have to edit to change settings like their outgoing mailserver? Thanks for all of your help!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
|
|
|
|
|
Did you look in the registry?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Totally forgot about that...doh! WIll check now
There are 10 kinds of people in this world. Those who understand binary and those who don't.
|
|
|
|
|
BrockVnm wrote:
Does anyone know what file (if there is any) I would have to edit to change settings like their outgoing mailserver?
Start with the HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\OMI Account Manager\Accounts registry key.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I shouldn't have initiated another thread really, but I think that, although the previous question is similar to this new one, this one I have stumbled across with is a bit different.
The question is I have shown a vertical scrollbar in a custom control (by calling ShowScrollBar , but, although I keep it updated by notifying it of the mins and maxes and the current position, it is behaving as if it was still expecting to be initiated: the bar doesn't work; you can't drag the bar as it is always in the same position; . . .
Are there any steps I am missing out here?
Thank you very much for your time.
David
|
|
|
|
|
Please give us a code fragment, so we might see, what's your problem. In general, scrollbars do their work.
|
|
|
|
|
Hi
You may have to add ON_WM_VSCROLL() to your message map and implement the function, maybe something like this, which works for me. Think I stole some of it from mfc's own CScrollView, take a look here too. Don't know why this doesn't work automatically inside mfc. I feel like (by calling SetScrollPos()) I'm telling the scrollbar something it actually already knows. Well mfc is not alway intuitive, and always trying to figure out "why" will make you go nuts . Who knows why scrolling works like this, am I completely out of track here?
- Jesper
void EPropListCtrl::OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar )
{
int nNewPos = -1;
int sp = GetScrollPos(SB_VERT);
if( nSBCode==SB_THUMBPOSITION || nSBCode==SB_THUMBTRACK )
{
nNewPos = nPos;
}
else if( nSBCode==SB_LINEUP )
{
sp -= 5;
nNewPos = sp;
}
else if( nSBCode==SB_LINEDOWN )
{
sp+=5;
nNewPos = sp;
}
else if( nSBCode==SB_PAGEUP )
{
sp-=20;
nNewPos = sp;
}
else if( nSBCode==SB_PAGEDOWN )
{
sp+=20;
nNewPos = sp;
}
if( nNewPos >= 0 )
{
SetScrollPos( SB_VERT , nNewPos );
Invalidate();
}
}
|
|
|
|
|
This is very distressing!
I have been taking a look at some sites and apparently there is much more to scrollbars than it actually seems to be at first.
Do you know if there is a (more) straight forward approach on how to [manually] program scrollbars?
David
BTW: Thanks a lot for the code -- it was very helpful.
|
|
|
|
|
I have around five years of mfc programming behind be, and one thing I've learned is that there is no such a thing as "forward approach". But as I mentioned before, looking at mfc's own scroll code may help you a great deal.
And btw, don't forget, you'll have to set the dc's viewportorg yourself before drawing in your OnPaint() function. This is what makes the control scroll its contents.
something like this (please forgive me if this doesn't compile, it's straight out of my mind..)
void SomeControl::OnPaint()<br />
{<br />
<br />
<br />
CPaintDC dc(this);<br />
int orgx = GetScrollPos(SB_HORZ);<br />
int orgy = GetScrollPos(SB_VERT);<br />
dc.SetViewPortOrg(-orgx,-orgy);<br />
<br />
<br />
dc.MoveTo(0,0);<br />
dc.LineTo(100,100);<br />
<br />
}
Good luck
- Jesper
|
|
|
|