|
Hi,
I'm creating an MDI App containing non rectangular dialog.
It seems to work well because I can see my bitmap and the region seems to be well defined. My problem is that the removed part of my dialog is supposed to allow me to see my app background. Unstead, I see my desktop. Also, when I'm resizing, the removed part of my dialog dont refresh.
I have redefined OnPaint() and OnCreate(), OnEraseBkGround()
int BitmapDlgBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialogBar::OnCreate(lpCreateStruct) == -1)
return -1;
// Load the image
m_hBmp = (HBITMAP)LoadImage(GetModuleHandle(NULL), "C:\\Bitmap.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if(m_hBmp == NULL)
{
AfxMessageBox(_T("Error opening the Bitmap!"));
return 0;
}
// create a compatible device context
// for the bitmap. we will use this
// DC when painting the image onto
// the background of the window.
//CDC* dc = GetDC();
//m_hBitmapDC = CreateCompatibleDC( dc->m_hDC );
//ReleaseDC( dc );
//m_hOrigBmp = (HBITMAP)SelectObject( m_hBitmapDC, m_hBmp );
HDC dc = ::GetWindowDC(this->m_hWnd);
m_hBitmapDC = ::CreateCompatibleDC( dc );
::ReleaseDC(this->m_hWnd, dc);
m_hOrigBmp = (HBITMAP)SelectObject( m_hBitmapDC, m_hBmp );
// convert image to region. assume a magenta transparency color.
m_imageWidth = 0;
m_imageHeight = 0;
WindowRegion rgn;
HRGN hBmpRgn = rgn.CreateRegionFromImage( m_hBmp, RGB(255,0,255), m_imageHeight, m_imageWidth );
m_imageWidth = rgn.m_dwWidth;
m_imageHeight = rgn.m_dwHeight;
// resize the window with its height/width based on that of the bitmap.
SetWindowPos( NULL, 0, 0, rgn.m_dwWidth, rgn.m_dwHeight, SWP_NOZORDER | SWP_NOMOVE );
// finally, ask Windows to force the
// window to take on the shape of the
// region.
// note: the System owns the region
// after this call so there is no need
// to release it manually.
SetWindowRgn( hBmpRgn, FALSE );
return 0;
}
void BitmapDlgBar::OnPaint()
{
if ( GetUpdateRect(NULL,FALSE) )
{
PAINTSTRUCT ps;
ZeroMemory(&ps,sizeof(ps));
CDC* dc = BeginPaint(&ps);
BitBlt( dc->m_hDC, 0, 0, m_imageWidth,
m_imageHeight,
m_hBitmapDC,
0, 0, SRCCOPY);
EndPaint(&ps);
}
}
Any Ideas?
Regards
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Create a function that does the specialized drawing you do in OnCreate(). Call that same function in OnPaint().
Kuphryn
|
|
|
|
|
Hi,
Thanks for the reply,
I'm not sure of what your telling me...Can you explains a bit?
Thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Hi,
I am posting again due to no one replied before to my post.
I have created a very simple activeX using VC++. When I add the ocx file to a web page, using microsoft activeX control pad, I can edit the properties I have created and send values to them, but if I want to send values using the <param /> tag, so the values will be send when the page is loaded, then nothing happend.
Can anyone please help?
"Learn from the mistakes of others.
You can't live long enough to make them all yourself."
"Failure doesn't mean I'm a failure, It does mean I have not yet succeeded;
Failure doesn't mean that I should give up, It does mean that I should try harder;
Failure doesn't mean that I will never make it, It does mean that I need more practice".
Thank you for helping.
|
|
|
|
|
Hi
I have this project that I'm working on. It's a SDI with a CFormView an it contains a Tabctrl which again contains a dialog for each tab. Every dialog, which is created dynamically, contains some dynamic buttons an other controls!
So my question is how do I create the messages for the controls to react on?
I dont know if my question is clear enough but ask if there is any doubt.
Thanks in advance!
Frank
|
|
|
|
|
Maybe this link[^] can be a beggining to answer your question.
~RaGE();
|
|
|
|
|
How do I dismiss a popup menu tracked on a tray icon after my callback has created the menu?
Inside the client it's easy:
GetMenu()->TrackPopupMenu(
uFlag,
ipMouse.x,
ipMouse.y,
this);
But it does not work for the tray!!!
This does not work either:
HWND hWndTB = ::FindWindow("Shell_TrayWnd", NULL);
::TrackPopupMenu(
GetMenu()->GetSafeHmenu(),
uFlag,
ipMouse.x,
ipMouse.y,
0,
hWndTB,
NULL);
???
Must be something like killing the menu modal loop I guess.
Regards Michael Mogensen /dk.
Regards Michael Mogensen /dk.
|
|
|
|
|
Try setting the forground window to the window of your app, showing the menu and then posting a null message to your window...
pWnd->SetForegroundWindow();
pMenu->TrackPopupMenu( ... );
pWnd->PostMessage( WM_NULL );
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
THANX'! It worked - perfect!
Michael Mogensen.
|
|
|
|
|
Hello,
how can i embbed a dialog in a my mainframe window?
Thanks, Mark
|
|
|
|
|
If you mean in the main client area, check out CFormView. When you run Appwizard, on the page towards the end (last or last but one) where it lists the classes that will be created, select your view class and select CFormView as the base class.
If you want to add a dialog as a toolbar, see the documentation for CDialogBar.
Hope this help!
|
|
|
|
|
Yep,in the client area. You mean with the class-wizard? I can't find the option there to change the base class.. ?
Thanks, Mark
|
|
|
|
|
No, in the App Wizard, when you first create the application. If you are doing it retrospectively, the best thing to do is to create a new project and then work out the differences in the generated code (changes will be mainly to the view and resources, but also possibly to the doc), merging the code into your existing project.
|
|
|
|
|
I habe a splitter Window with an Edit View and a CListView.
hello !!!
Now I have a shared sroll bar making with :
m_wndSplitter.SetScrollStyle(WS_VSCROLL);
Now the Edit View is reacting on the shared scroll-bar, but the ListView
has its own scroll-bar and is not reacting on the shared scroll bar.
So, what can I do, that the ListView has no scroll bar and that it is reacting on the shared scroll-bar???
Both Views must synchronous scroll with the shared scroll-bar.
Thank you for helping me,
cu
schoni
|
|
|
|
|
I'm using a technique I found here on code project to embed a combo box in a toolbar. Because my toolbar uses large 32x32 buttons, the toolbar spacer line (the "placeholder") behind the combo box is visible.
Any ideas on how not draw the line? (making it hidden eliminates it from the toolbar)
|
|
|
|
|
|
Hi,
I have a problem, I have an installation set for DAO36, and it tries to self register DAO2535.TLB... after that I get an error message...
Does make sense install a TLB ??? ( I think not as far as it don't have any registry information, I'm right ?).
Greetings
Braulio
|
|
|
|
|
Hi world,
What's the best solution to find the pointer which caused a memory leak?
I don't use MFC (and doesn't want to use it)!!! Is smart pointer a good solution?
Thanks for any advice...
Hello World!!!
from Raphaël
|
|
|
|
|
You can use the CRT Heap check functions:
#include "crtdbg.h"
#if defined(WIN32) && defined(_DEBUG)
const int _CrtDbgFlags =_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
_CrtSetDbgFlag(_CrtDbgFlags|_CRTDBG_LEAK_CHECK_DF);
#endif
I think there is a recent article here on CP about overiding new and delete to locate memory problems as well.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi,
http://www.codeproject.com/script/comments/forums.asp?msg=491851&forumid=1647&mode=all&userid=161454#xx491851xx
-----------------------------------------------------------
Hi,
Regarding the technique of dumping in-memory statistics, is
given below
Note: memstate1 takes snapshot of pre-memory leak and
memstate2 takes snapshot of post-memory leak. finally,
memstate3 makes the statistics based on both the snapshots.
CMemoryState memState1, memState2, memState3;
void CHello::MakeMemoryLeak()
{
memState1.Checkpoint();
LPCTSTR strMemoryLeak = new char[50];
memState2.Checkpoint();
memState3.Difference(memState1, memState2);
memState3.DumpStatistics();
}
Hope this Helps
Regards
~Hari~
|
|
|
|
|
And without MFC...???
Hello World!!!
from Raphaël
|
|
|
|
|
Hi,
Its not MFC. Basically, it uses _CRT... Functions/Flags only.
But the thing is, CMemoryState is declared & defined AFX.H/AFXMEM.cpp respectively. Just have a look at the code, if possible write your own.
Hope this helps.
|
|
|
|
|
I use macros as a wrapper to the malloc, realloc and free functions. This way I can log all my memory allocations to a file, the following is a bit complicated, but works:
#define realloc(PTR, SIZE) \
logReallocPtr(PTR, realloc(PTR, SIZE), ck_memsize(PTR), SIZE, __FILE__, #PTR, __LINE__, NULL)
#define malloc(SIZE) \
logReallocPtr(NULL, malloc(SIZE), 0, SIZE, __FILE__, #SIZE, __LINE__, NULL)
#define free(PTR) \
logReallocPtr(PTR, NULL, ck_memsize(PTR), 0, __FILE__, #PTR, __LINE__, free)
// This function gets called for every malloc, realloc and free
void *logReallocPtr(void *oldPtr, void *newPtr, size_t oldSize, size_t newSize, const char *file, const char *func, size_t line, void(*_free)(void*)){
char modFile[MAX_PATH];
int i=strlen(file)-1;
FILE *out=NULL;
if(!oldPtr && !newPtr) return NULL;
while(out==NULL) out=fopen("\\debug_alloc.txt", "ab");
strcpy(modFile, file);
while(i>=0){ if(modFile[i]==':') modFile[i] = '_'; i--; }
if(out){
fprintf(out, "%d:%s:%s:%d:%d:%.8x:%.8x:%d:%d:\r\n", (int)time(NULL), modFile, func, line, getpid(), (size_t)oldPtr, (size_t)newPtr, oldSize, newSize);
fclose(out);
}else{
fprintf(stderr, "%d:%s:%s:%d:%d:%.8x:%.8x:%d:%d:\r\n", (int)time(NULL), modFile, func, line, getpid(), (size_t)oldPtr, (size_t)newPtr, oldSize, newSize);
}
if(_free && oldPtr) _free(oldPtr);
return newPtr;
}
|
|
|
|
|
Oh, and ck_memsize(PTR) should be replaced with _msize(PTR).
|
|
|
|
|
Anybody knows about GDI system calls hooking?
vikramvs
|
|
|
|
|