|
Sorry - you can't use MFC runtime type information with templates. IMPLEMENT_SERIAL/DYNCREATE/DYNAMIC will not work - that's because MFC creates some global variables named after your class name. With templates it simply doesn't work.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Many Thanks for your respond, it will avoid me long hours of research )
|
|
|
|
|
Sirs,
do you know how to create a property sheet or even a simple dialog in one pane of an SDI splitter window?
I have tried following code:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
{
//creating 1 row and 2 cols
BOOL bCreateSplitter= m_wndSplitter.CreateStatic(this, 1, 2);
//creating views
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CFirstView),CSize(100,100), pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CSecondView), CSize(100,100), pContext);
return bCreateSpltr;
}
where CFristView and CSecondView are generated by the class wizard, and FirstView.h and SecondView.h are included in MainFrm.h.
When CFristView and CSecondView are derived from CView everything is OK, it compiles and runs OK.
When the panes base class is a CFormView or CPropertySheet then it compiles though but asserts before creation of mainframe. When the base class is a CDialog or CWnd the code does not even compile ("classCFirstView is not a member of CFirstView").
Thank you for your help in advance.
Bunburry
Education is an admirable thing but it is well to remember from time to time that nothing that is worth knowing can be taught (O.Wilde)
|
|
|
|
|
Are you sure your IMPLEMENT_DYNCREATE has the right arguments when you change the base class? Also pay attention to the message map macro BEGIN_MESSAGE_MAP.
To be sure you correctly replaced the base class use the "Replace" command in VS.
Paolo.
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi @ all
I'm doing an internship in a software company. One of my tasks is testing modules.
After seperatly compiling the modules I get objectfiles, exe files and so on.
So where can I get some information about linking the seperate parts (to create several test scenarios)? Could anybody help me with the link.exe options (perhaps a link to a good documentation or example)?
Thanks a lot
|
|
|
|
|
Probably covered. Probably easy. I tried using a CStatic control but ultimately it looked as though it failed. I'm wondering if there is still an easy solution to printing bitmaps from screen to paper or if the solution is convoluted. If it is a difficult solution then might you know where I can find some documentation on the matter?
Thanks!
Chris
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
Start a new app from AppWizard, and check "Pinting", this enable print and print preview to your CView.
Then draw your bitmap on the OnDraw method of your view. That's all.
// PrintTestView.cpp
BEGIN_MESSAGE_MAP(CPrintTestView, CView)
//{{AFX_MSG_MAP(CPrintTestView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
void CPrintTestView::OnDraw(CDC* pDC)
{
CPrintTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBitmap bmp;
if (bmp.LoadBitmap(IDB_BITMAP1))
{
// Get the size of the bitmap
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
// Create an in-memory DC compatible with the
// display DC we're using to paint
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
// Find a centerpoint for the bitmap in the client area
CRect rect;
GetClientRect(&rect);
int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;
// Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
}
}
/////////////////////////////////////////////////////////////////////////////
// CPrintTestView printing
BOOL CPrintTestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
|
|
|
|
|
Hi, I have a very simple problem here deciding whether to use an STL
vector or an STL list.
The list is a list of std::string
Basically, this how I am going to use this list:
1) Populate once, then leave untouched
2) Check if a string exists in the list
Does anyone know if I should use vector<string> or list<string> ?
Thanks!
Jeremy
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
1) Populate once, then leave untouched
So list doesn't have any advantages over vector in this case - use vector or map if you're going to frequently check if string exists.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I wouldn't use a vector or a list for this task. Use a vector for containing items where random access to the items is important, and there is a definite order to them. Use a list where you plan on accessing the items sequentially, and the order of insertion is maintained.
If you want to keep container of strings and you want to check later whether or not a string exists, consider using a set. The items in the set will be maintained in sorted order (not in order of insertion), only unique items will exist in the set (you won't be able to "Bob" in there twice). Use a set if the order in which you inserted the items into the container is not important. Use the set::find method to determine if an item already exists in the set. This will save you the trouble of traversing the entire container to find out if an item exists in the set. Also, since sets store their contents in a tree, determining if an items already exists in the set is less computationally expensive than determining if an items exists in a linear sequence (like a list or vector).
|
|
|
|
|
With list or vector you can perform only linear search . With set (which is a balanced binary tree) you use binary search, and that is a lot faster.
I vote pro drink
|
|
|
|
|
Others have already mentioned set, so I won't repeat them.
However, for future reference, the advantage of list is that it allows easy insertion/deletion in the middle, vector would need to reallocate the entire array to do this. The down side is that list cannot be randomly accessed - you need to start at the top and work your way through to find a particular location.
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.
|
|
|
|
|
Thanks a lot guys! I found your suggestions very, very helpful.
Jeremy.
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
I'm writing a DLL that uses DirectShow to capture some video off a firewire (WDM) device, and I'm having a small problem.
We have an MFC app that creates the view in the EXE, and then passes a pointer to the view to the DLL so that we can put the preview window into the view. If the preview window consumes all of the client rectangle, I can't get the veiew to respond to mouse clicks. If I maximize the view window, I get a border of unused area around the preview window that responds to mouse clicks.
Can anyone provide any clues,documentation, books, magazines, help from aliens, anything?
|
|
|
|
|
Can you call SetCapture() in your view ? That's how I usually get around those sort of problems, although I often find it's tricky to get the code to a state where the mouse actually responds as you'd expect.
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 basically can't change the exe. Anything I do has to be done in the DLL since we support many different DLL which perform similar functionality, using WDM instead of Video For Windows.
|
|
|
|
|
I've got myself a treeview (yeah!). When I select a node, the tvitem structure I get with the message doesn't contain the image (TVI_IMAGE) attribute. Is there a way of finding out what image the selection has? I'd like to use the image as a way of knowing what type of object was selected.
Thanks,
WAVK
|
|
|
|
|
You'll have to call CTreeCtrl::GetItem, passing HTREEITEM from NMTREEVIEW. Don't forget about TVIF_IMAGE flag.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I need to know when my parent gets WM_SIZE and WM_MOVE messages (i am a CButton derived control )
any help?
|
|
|
|
|
Your parent must co-operate and call some method exposed by button. There's no built-in notification going from parent to child during move/size operations.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello, the codegurus around the world.;)
We can put the code likes SendMessage with the user-defined message or some Get function
from Dialog (or button) in WM_SIZE and WM_MOVE of the parent's message handler.
The only issue is how we get CWnd of the child dialog or the button of its dialog.
There are many ways to do this.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
How can I force all buttons, edit- boxes and list-boxes to be resized when resize the application window ? Objects should be smaller but still at the same location within the application window.
Hans
|
|
|
|
|
If you're using MFC you may have a look at ResizableLib on this site.
If using plain Win32 APIs, that same article can give you some ideas.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
this is the easiest way to place an icon on a button:
// Button = m_SafeButton
// Icon = IDI_FLOPPY
m_SafeButton.SetIcon(AfxGetApp()->LoadIcon(IDI_FLOPPY));
m_SafeButton.EnableWindow( true);
that´s all.
Hans
|
|
|
|
|
i am using NtQuerySystemInformation() from NTDLL.
my worry is whether this function will be supported in future versions of Windows.
isn't XP the next version of Win2k and ME that of Win9x??
i am unfamiliar with Windows Architecture...could someone help me out??
|
|
|
|