|
The release exe works fine. The debug is crashing at the calll to CDialog Create()
BOOL CDisplayInfoList::Create(UINT nID, CWnd *pWnd, const CString* keys, int keysSize, std::set<CString>* pKeySet)
{
m_pParentWnd = pWnd;
m_pKeySet = pKeySet;
m_allKeysArray = new CString [keysSize];
m_arraySize = keysSize;
for (int i =0; i < keysSize; i++)
{
m_allKeysArray[i] = keys[i];
}
<code>return CDialog::Create( nID,pWnd);</code>
}
Its just a popup resizing dialog with a clistctrl and two buttons.
What shall I suspect? THe call is :
CDisplayInfoList* pDisplayInfoList = new CDisplayInfoList;
if (pDisplayInfoList == NULL) return;
<code> BOOL ret = pDisplayInfoList->Create(IDD_DISPLAYINFOLIST, this, goodFields, flds.size() ,&(pDoc->m_keySet));</code> if(!ret)
{
AfxMessageBox("Error creating viewbox");
delete pDisplayInfoList;
return;
}
winocc.cpp line 259, where its saying its not IsWindow:
int CWnd::GetDlgCtrlID() const
{
ASSERT(::IsWindow(m_hWnd));
|
|
|
|
|
sorry its line 279...in
void CWnd::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint)
{
ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlSite == NULL)
::MoveWindow(m_hWnd, x, y, nWidth, nHeight, bRepaint);
else
m_pCtrlSite->MoveWindow(x, y, nWidth, nHeight, bRepaint);
}
and stops in this if I set a breakpoint in it....
|
|
|
|
|
I made a new identical class but named its resource and classname shorter. One of the two factors (maybe both) made the debug version happy too. I didnt realize there was a limit to the length of the names????
|
|
|
|
|
Hi everyone!
I'm creating a Dialog based Win32 Application. One of my controls is a picture control.
How can i load and display an image(bitmap) on this control???
Should I subclass the picture control???
Please send an example if you can!...
Thanks!!!
|
|
|
|
|
If the bitmap is in the program resources you just set the "type" (in its properties) to Bitmap then choose the bitmap id from the "image" field.
If you need to load images using code this is a sample code for loading a bitmap from file into a static control (picture control is actually a static control with SS_BITMAP style).
The code assume that you have a picture control with ID IDC_MYPICTURE (if you left the default ID, IDC_STATIC, the code will fail) and styles set to real image size (SS_REALSIZEIMAGE ) and type is bitmap (SS_BITMAP ).
HBITMAP hBmp = (HBITMAP)LoadImage(NULL, fileName, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
CStatic * pStatic = NULL;
pStatic = ((CStatic*)GetDlgItem(IDC_MYPICTURE));
if(hBmp && pStatic)
{
HBITMAP hOldBmp = pStatic->GetBitmap();
DeleteObject(hOldBmp);
pStatic->SetBitmap(hBmp);
}
|
|
|
|
|
Could you please tell me how to do that in win32 API???
|
|
|
|
|
Sorry, did not notice.
This is the same code but using Win32 APIs:
HBITMAP hBmp = (HBITMAP)LoadImage(NULL, fOpen.GetPathName(), IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
HWND hWnd = ::GetDlgItem(hDlg, IDC_MYPICTURE);
if(hBmp && hWnd)
{
HBITMAP hOldBmp =
(HBITMAP) ::SendMessage(hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0);
if(hOldBmp)
DeleteObject(hOldBmp);
::SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBmp);
}
|
|
|
|
|
|
hey....you can do it with SetBitmap() function of CStatic class.
C.R.Naik
|
|
|
|
|
is there any way to create instances of classes indirectly
for example in
myClass myObject;
or
myObject = new myClass;
is there a way i could make myClass a variable containing the name (or something) of the class i wanted the item to be.
I would like to be able to get away from this unfortunate and annoying hardcoding of class creation, but i dont have a clue how to do it
Any Ideas???
|
|
|
|
|
Chicken64 wrote:
I would like to be able to get away from this unfortunate and annoying hardcoding of class creation, but i dont have a clue how to do it
Not sure if this is what you want. But take a look at :- Accessing Run-Time Class Information on MSDN. If you don't find that search for RUNTIME_CLASS macro
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Chicken64 wrote:
is there a way i could make myClass a variable containing the name (or something) of the class i wanted the item to be.
some languages allow this, but C++ isn't one of them.
the best you can do is to create a "class factory" where you can do something like:
CBaseClass * pObj = factory.MakeNewObjectFromName(csClassName);
and that function would have to compare csClassName to a set of names.
using COM, you can get more abstract, since the list of names is dynamic (UUIDs and CLSIDs) and maintained by the OS. all you have to do is come up with a way to tie the object you want to create to the list of names/IDs that the OS maintains. it can get complicated.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
thanks for the help, i guess its good to know it cant be done (stops me trying to figure out how to do it)
oh well, i might well try that class factory thing
thanks again, Chicken64
|
|
|
|
|
I want to hook the createfile API.
Whenever a file is being created or modified i need to receive the alert so that i can check who is creating/modifying the file..after i verify the user and his quota..then i can allow creating the file or deny his request.
ANY idea on how to do this???
Ill be forever grateful to anybody who helps!!
|
|
|
|
|
|
in MSDN search :
Monitoring Changes in a Directory or Directory Tree..
this allows u just to monitor changes. not to make you allow it or not
|
|
|
|
|
Hi
I'm using FindNextFile() to extract file.Problem is i need to extract them in numerical order.I had ordered them proper through Windows explorer, but it seems that FindNextFile() doesnt retrieve the files in that order. Is it not supposed to retrieve the files in order?
Is there any way i can retrieve the files in order?
thks
|
|
|
|
|
raner wrote:
Is there any way i can retrieve the files in order?
no. you will have to sort the files yourself.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
raner wrote:
Is it not supposed to retrieve the files in order?
Yes, but the order is completely dependent on what the underlying filesystem defines it to be.
|
|
|
|
|
Hi. Im developing a pure-unmanaged VC++.NET windows application and i wanted to use a tool for print preview and printing.
- I dont require a tool that accesses the DB and fetches the data to make a report.
- I dont require web integration
- I DONT WANT to use managed code!!
- It should accecpt RTF text
- ...
I was thinking on crystal reports, but ive visited their site and that thing is huge! It has reports for everything and for everyone, and i didnt found a good start point on which to start. Anyone knows a set of examples or projects i could start on? I use VC++ .NET but i dont want to use managed code.
Thanks in advance!
|
|
|
|
|
Considering all your requirements (and explicitly stated non-requirements), have you considered WordPad?
No, seriousy - it AFAIK fulfills all of your requirements.
|
|
|
|
|
Hi all, I've dialog which has clistctrl and two buttons.
I want to know how to change the specifice item text color as I inserting into the clistctrl.. I'm not using listview.
Can I set the item text with the color text?? I mean.. we can setdlgitem text color using CFont.. I dont' know if there is a way to set the item text color doing so.
thank you
|
|
|
|
|
As far as I know there is no possible way to set an indiviual item text's color (not all items as a whole) except by making an owner draw list control.
|
|
|
|
|
Ok.. so how about setting the item images..
I tried
<br />
m_myListCtrl.SetExtendedStyle(LVS_EX_SUBITEMIMAGES |LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES |LVS_EX_FLATSB );<br />
m_TFImages->Create(IDB_TRUE_FALSE, 16, 2, RGB (255,255,255));
<br />
m_myListCtrl.SetImageList(m_TFImages,LVSIL_STATE);<br />
m_myListCtrl.InsertColumn(0,"");<br />
m_myListCtrl.InsertColumn(1,"");<br />
<br />
I got run time error and the program get crashed...
I looked at in MSDN code sample CListCtrl::SetImageList
I have an idea of setting the item state instead of changing the color of item text..
Oh.. I also have checkboxes beside the items and now i want to add picture beside the item text...
Could you help me how to do it??
Thank you
|
|
|
|
|
Well! First of all ensure that the CImageList variable is not destroyed within the scope of the list control variable, in English that is declaring it as a global variable or a member data in the CDialog class. This is to prevent destruction of the image list before the destruction of the list control. If you did this and the crash is still there then the problem is not in the few code lines you are writing in your post.
An item's image is set during insertion,
CListCtrl::InsertItem(nItemNumber, "ITEM NAME", nImageListEntryNumber);
To change the image of an already inserted item you should use CListCtrl::SetItem like this
LVITEM item;
item.mask = LVIF_IMAGE;
item.iItem = nItemIndex;
item.iSubItem = 0;
CListCtrl::GetItem(&item);
item.iImage = nNewImageIndex;
CListCtrl::GetItem(&item);
this works for first subitem's image setting, if you need to set subitem's image (you use LVS_EX_SUBITEMIMAGES) there is no way but to use
CListCtrl::SetItem
|
|
|
|