|
Overloaded_Name wrote: It gives debug assertion
Yes, but what assertion; what is the value (or missing value) that actually causes the assertion?
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
It just takes me to this line in afxcmn.inl
{ ASSERT(::IsWindow(m_hWnd)); return CTabCtrl::InsertItem(TCIF_TEXT, nItem, lpszItem, 0, 0); }
If I see in the locals then I find these values
this 0x0019fc18 {CMyTabCtrl hWnd=0x00000000} CTabCtrl * const
nItem 0 int
If there is something else I should look for, then tell me.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
That clearly shows that CMyTabCtrl has not been created properly, as it does not have a Window associated with it. You need to look at where you create it to try to discover why the create is failing, or why it has not been called properly.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Since the assertion indicates that the mhWnd is NULL, the problem lies in this area:
Overloaded_Name wrote: BOOL CMainDialogDlg::OnInitDialog()
{
tabCtrl = new CMyTabCtrl;
tabCtrl->InitizlizeTabs();
}
The first line creates an instance of the class, but does not create the window associated with it.
The second line tries to insert information into the window - but there is none.
As Richard MacCutchen said, you need to Create the tab control.
Hope this helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Well spotted, I failed to notice this obvious mistake.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
krmed wrote: The first line creates an instance of the class, but does not create the window associated with it.
Ok. I understand where the problem lies. But that's what I stated in my OP. If I do this application normally, like #including the tab files in the Tab Ctrl header file and then, #including this tab cntrl header file in the main dialog header file. And finally when I do
CMyTabCtrl tabCtrl;
tabCtrl.InitializeTabs();
It works perfectly. However thank you for your time. I am trying to do this, in this way as well.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Hi to all, I am subclassing an EDIT Control. But the WM_CREATE is not fired in Subclassed Procedure EditProc. What is wrong, i am unable to find. I had tried WM_NCCREATE also, but failed.
pls help..
#include <Windows.h>
#include "resource.h"
WNDPROC OldEditProc;
HINSTANCE hInst;
HFONT hFont;
WNDPROC SUBCLASS(HWND hControl,WNDPROC newWindowProc)
{
return (WNDPROC)SetWindowLong(hControl,GWL_WNDPROC,(LONG)newWindowProc);
}
LRESULT CALLBACK EditProc(HWND hWnd,UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_CREATE:
SetWindowText(hWnd,L"Welcome");
break;
}
return OldEditProc(hWnd,Msg,wParam,lParam);
}
LRESULT CALLBACK stdEditProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_INITDIALOG:
OldEditProc = SUBCLASS(GetDlgItem(hWnd,IDC_EDIT1),EditProc);
break;
case WM_CLOSE:
EndDialog(hWnd,TRUE);
break;
}
return FALSE;
}
INT APIENTRY wWinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPWSTR lpCmdLine, __in int nShowCmd )
{
hInst = hInstance;
return DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG1),NULL,(DLGPROC)stdEditProc);
}
Regards,
Vishal
|
|
|
|
|
WM_CREATE and WM_NCCREATE will not be sent to the sub-classed procedure because they have already been sent to the original procedure. But you will get other WM_COMMAND messages and notifications.
|
|
|
|
|
got it, but one small doubt, if i want to set font for a control i usually do it in WM_INITDIALOG or WM_CREATE section, but in this case which Message has to be used for setting font, As i had found this can be done in WM_PAINT section also, but WM_PAINT is triggered every now and then, resulting in extra overload. Please guide which message will be better to set a font for a control in its subclassed procedure.
Thanks..
Regards,
Vishal
|
|
|
|
|
So if you do this before you sub-class the control in the original procedure, does it change after sub-classing?
Don't do it in WM_PAINT . It will be an unnecessary overhead.
Instead, you could define a custom message and do a PostMessage with the custom message to the control after it is sub-classed in WM_INITDIALOG .
|
|
|
|
|
thanx, I will check and update the result. Thanx once again for your guidance.
Regards,
Vishal
|
|
|
|
|
Hi, is there any possible way how to find in a directory where are the different files such as binary, batch, text files and so on, with help by (ifstream, fopen ...) will be always guaranteed that will be opened only the text files??
I imagine the code like that, but this opened a binary files too. Which I don't want. Thank you for your help.
data - is a directory, secretFile - is a file, which I don't know what type it is
string line;
ifstream myfile("data/secretFile");
if (myfile.is_open())
while ( myfile.good() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file, it's probably might not a text file" << endl;
Thank you for your help.
|
|
|
|
|
You can look at the filename extensions and make assumptions about the content. For example, .exe , .obj and .dll files are expected to contain binary data, and .txt , .ini and .bat are expected to contain text. However, nothing is guaranteed as anyone can create a file with any extension but put their own content inside it. You can examine the content for leading text identifiers (see my tip[^] for further information), CR/LF sequences etc, but again, there is no guarantee that the complete file content will be in the format you assume.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Thank you I'll look at it
|
|
|
|
|
If you only want to check the filename extension, you can use the _findfirst and _findnext functions or the FindFirstFile and FindNextFile APIs.
|
|
|
|
|
My machine is 64 bit. I have installed visual studio 2005, which by default installed in Program Files(x86). When i start visual studio I am not getting the option of win64 in the configuration manager. Please help me how can I get the option, do I need to reinstall it. I installed it 2 times but still the win64 option not coming. Please help. Thanks Sujan
|
|
|
|
|
|
Hi,
Did you actually install the 64 bit compiler? I am fairly certain that VS2005 does not install the 64 bit compiler in the 'default' installation. You will need to manually choose the 64 bit compiler during the installation.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor is right. VS2005 does not install the 64-bit C++ compiler by default.
So reinstall VS and this time select custom install and check on the 64-bit compiler in components listed.
|
|
|
|
|
you can add x64 support with a 'repair' or 'modify' (forget what they call it these days). no need to install from scratch.
|
|
|
|
|
except for the Express versions AFAIK, they don't offer any choice and always build for "AnyCPU" (unless you start hacking the project files).
|
|
|
|
|
Hello!
I am woring on an MFC app that previews a html page... it works with CHtmlView which uses Internet Explorer.
Is there a way I could preview using FireFox or any installed browsers? Some sort of ActiveX control...
I would like to stay within the app... and trap events (like form submission and ajax)
Any pointers welcome!
Jerry
|
|
|
|
|
|
Oh you good man! Thank you!
|
|
|
|
|