|
I don't know if there is a way to delete a member variable automatically, but I can't figure it out. Like in Visual C++ 6, if you add a member variable, you can go to the class wizard and remove it. Visuall C++ 6 automatically remove that variable from the project automatically.
But I could not find way to delete a member variable in Visuall C++.net. I have to go to the class to manually remove it, then I have to manually delete it from the DDX control as well.
Is there another way to delete member variable in VC++.net as does in Visual C++ 6?
|
|
|
|
|
I am not aware of any such possibilities in .NET but you could simply use the "Find in Files" utility giving your memeber variable as the search word which gives you a list of all accurances of this word.
Bunburry
|
|
|
|
|
Here is how i get that list : i call GetTrueTypeFonts with chtypeface = "" (see code);
EnumFontFamiliesEx calls the call back functions GetFaceName and GetStyleName.
Problem : if i test with FontData.lfCharSet = ANSI_CHARSET
i don't get fonts such as wingdings, symbols, .... (these fonts contain 'decorative' symbols). If i use DEFAULT_CHARSET, i get those wingdings etc... , but lots of the fonts included with ANSI_CHARSET are now missing.
The documentation says :
"If set to DEFAULT_CHARSET, the function enumerates all fonts in all character sets. If set to a valid character set value, the function enumerates only fonts in the specified character set."
So i thought that i would get all with DEFAULT_CHARSET.
(MapDefPolice is a CMap that collect all the fonts)
void GetTrueTypeFonts(const char *chtypeface, MapDefPolice *pMap)<br />
{<br />
LOGFONT FontData;<br />
strcpy(FontData.lfFaceName, chtypeface);<br />
FontData.lfPitchAndFamily = 0;<br />
FontData.lfCharSet = ANSI_CHARSET;<br />
HDC hDC = ::GetDC(NULL);<br />
EnumFontFamiliesEx(hDC, &FontData, <br />
chtypeface[0] ? (FONTENUMPROC)GetStyleName : (FONTENUMPROC)GetFaceName, <br />
(long)pMap, 0);<br />
::ReleaseDC( NULL, hDC);<br />
}<br />
<br />
int CALLBACK GetFaceName(ENUMLOGFONTEX *lpelf, NEWTEXTMETRIC *lpntm, DWORD FontType, LPARAM lParam)<br />
{<br />
if (FontType & TRUETYPE_FONTTYPE)<br />
GetTrueTypeFonts(lpelf->elfLogFont.lfFaceName, (MapDefPolice *)lParam);
return 1;<br />
}<br />
<br />
int CALLBACK GetStyleName(ENUMLOGFONTEX *lpelf, NEWTEXTMETRIC *lpntm, DWORD FontType, LPARAM lParam)<br />
{<br />
DefPolice *pDefPolice;<br />
long ID = GetTrueTypeID(lpelf->elfLogFont.lfFaceName, lpntm);<br />
MapDefPolice *pMapDef = (MapDefPolice *)lParam;<br />
pDefPolice = new DefPolice;<br />
pDefPolice->No = ID;<br />
ZeroMemory(&pDefPolice->Bits, sizeof(FontBits));<br />
pDefPolice->Bits.state = FONT_STATE_NEW;<br />
pDefPolice->strDescription = lpelf->elfLogFont.lfFaceName;<br />
pDefPolice->strDisplayName = lpelf->elfFullName;<br />
pDefPolice->Bits.weight = lpelf->elfLogFont.lfWeight;<br />
pDefPolice->Bits.bItalic = lpelf->elfLogFont.lfItalic;<br />
pDefPolice->Bits.bBold = ((lpntm->ntmFlags & NTM_BOLD) != 0);<br />
pDefPolice->Bits.bTrueType = 1;<br />
pMapDef->SetAt(pDefPolice->No, pDefPolice);<br />
return 1;<br />
}
|
|
|
|
|
Odd. Are you sure that FontData.lfFaceName is '\0' ? Is the value for FontData.lfPitchAndFamily filtering anything out?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Problem solved : the fonts wingdings, symbols, ... are in the SYMBOL_CHARSET charset.
So a first call with FontData.lfCharSet = ANSI_CHARSET will get the standard fonts, and a 2nd call with FontData.lfCharSet = SYMBOL_CHARSET get the rest.
|
|
|
|
|
how to implememt "search text" in CHtmlView?
includeh10
|
|
|
|
|
|
A call to any CTime member function causes unhandled exceptions, access violation. Any ideas why?
|
|
|
|
|
Daniel1324 wrote:
Any ideas why?
Not without a code snippet that exhibits the problem.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
|
I'm curious what you expected to come from an uninitialized object? Even though CTime::GetYear() is dereferencing a NULL pointer, it doesn't make sense that you'd assume valid data would be returned.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
My fault. I was assuming that it would return date and time stored in the system.
|
|
|
|
|
Is there a way to assign a version number to any type of file?
INI, DOC ... TXT.
thank you
|
|
|
|
|
If the file is part of some 'version control' system, then you likely can do what you are after. But the short answer is no, I think.
Chris Meech
It's much easier to get rich telling people what they want to hear. Chistopher Duncan
But for a man, barbecuing eggplant and portobello mushrooms is a sure way to have people question your sexual orientation. Kuro5hin
|
|
|
|
|
Yes. Within Windows Explorer, right-click the file and select Properties. Click the Summary tab. Enter a version number in the Revision Number box. This number, and the other pieces of information, are stored in the file itself. This is called structured storage.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
how to search post in the forum?
i.e. i need info about "CRichEdit", but i only get "aticles", not posts.
how to do the search, or where is the search engine?
thanks
includeh10
|
|
|
|
|
|
thx, it is what i'm looking for
includeh10
|
|
|
|
|
Hi there'
how can I add buttons to dialog titlebar? I want to create my own buttons aside to min/max.
thanks
Yaniv
![Confused | :confused:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_confused.gif)
|
|
|
|
|
You have to simulate the button yourself. You cannot add a button to the non-client area. You will need to draw the button yourself, and also handle the WM_NCLBUTTONDOWN and other messages to simulate the button corretly. Its a real pain from what I hear (never done it myself).
Sounds like a good idea for an article.... I may go and work out how to do it. If I get time, or you could post a solution yourself if get one that works.
Roger Allen
Sonork 100.10016
Death come early, death come late,
It takes us all, there is no reason.
For every purpose under heaven,
To each a turn, to each a season.
A time to weep and a time to sigh,
A time to laugh and a time to cry,
A time to be born and a time to die.
Dust to dust and ashes to ashes,
And so I end my song.
|
|
|
|
|
Hello, I am a novice C++ programmer, I wrote a OCX control for use in Visual Basic using MFC. The problem is I want to extend the number of parameters that I pass to the methods by using a object instead of "simple" strings and integers. I also want my events to pass this object back.
Currently mode method is called from VB like
Height = 44
Width = 33
Call MyOCXControl.DrawRect( Height, Width )
I want to change this to (this is the Visual basic part)
Set Myobject = New ComObject.Container
MyObject.Height = 44
MyObject.Width = 32
MyObject.Title = "Hello world"
Call MyOCXControl.DrawRect(MyObject)
As you can see, I need to know how to create a "MyObject" in C++ and have Visual Basic understand it's interface. As well I need to let my existing OCX (MyOCXControl) allow this MyObject to passd to it.
I see lots of example of writing a OCX but none that explain how to do this. Source code illistrating this would be awsome.
Thanks in advance.
|
|
|
|
|
My experience with this sort of thing is a little rusty now, but should have enough information get you started.
You need to understand a little more about how COM (Component Object Model) works, but it should be relatively straightforward from that point.
ActiveX controls (your OCX) are based on COM as well, so what you need to do is write your "MyObject" as another COM object using MFC or ATL. Then you can pass the object from VB into your control.
The function you write on the C++ side of your ActiveX control I think should take a pointer to IUnknown or IDispatch. Once you have this pointer, you can QueryInterface for your own interface (or call Invoke() if it's IDispatch), and pull the height and width, etc values from there.
I'm sure some COM gurus can fill in/correct anything important I've missed.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
I have a MS Visual Studio .NET 2003 C++ MFC CFormView class GUI which has a Picture Control in the dialog. I need to load .bmp, .jpg, or .tiff into the picture control, so I’m using GDI+. I got it to load the picture, center it, and stretch it into the control. I could then pick and load a 2nd one if desired which would overwrite the first. It all seemed good, but if it had to repaint the window it would crash (this included minimize/maximize the child or main window or anything blocked part or all of the image then moved).
I found a problem where the image resizing could cause the image to be slightly larger than the picture control rectangle. I fixed that, and the crashes stopped. However, the image would just disappear (if any of the things listed above happened). I would have to re-choose the image.
After doing some other things I’m back to the crashes. I can’t figure out what’s going on. Here’s the errors:
Microsoft Development Environment pop-up error message:
Unhandled exception at 0x00000003 in NodeGUI.exe: 0xC0000005: Access violation reading location 0x00000003.
It shows the gdiplusgraphics.h file with a green arrow pointed at the (next to last) height line below:
Status DrawImage(IN Image* image,
IN INT x,
IN INT y,
IN INT width,
IN INT height) {
return SetStatus(DllExports::GdipDrawImageRectI(nativeGraphics,
image ? image->nativeImage
: NULL,
x,
y,
width,
height));
}
The output file also shows the following:
The thread 'Win32 Thread' (0x748) has exited with code 128 (0x80).
The thread 'Win32 Thread' (0x4e0) has exited with code 128 (0x80).
The thread 'Win32 Thread' (0x62c) has exited with code 128 (0x80).
The thread 'Win32 Thread' (0x728) has exited with code 128 (0x80).
The thread 'Win32 Thread' (0x600) has exited with code 128 (0x80).
The program '[1252] NodeGUI.exe: Native' has exited with code 128 (0x80).
Here’s the relevant code I’m using:
void CNodeGUIView::OnPaint(){
CPaintDC dc(this); // device context for painting
//m_st1 is the static picture control
//defined by DDX_Control(pDX, IDC_MapImage, m_st1);
CDC* map = m_st1.GetDC();
Graphics mapGraphics(map->m_hDC);
//imgX is the image width, imgY the image height,
//centerX & centerY are the coordinates of the
//top left corner where the image should be
//placed in the static picture control
imgX = 1; imgY = 1;
centerX = 0; centerY = 0;
//the PictureManip class correctly sizes and places
//the image
//it returns (by reference) the proper coordinates
PictureManip::ChangePicSize(picCtrlWidth,
picCtrlHeight, imageWidth, imageHeight, imgX,
imgY, centerX, centerY);
//mapPtr is the Image* to the image file
mapGraphics.DrawImage(mapPtr, centerX, centerY, imgX,
imgY);
mapGraphics.ReleaseHDC(map->m_hDC);
map = NULL;}
I’ve commented out the last two lines (to not release anything) with no change. Is there a validation/invalidation I need to do?
As far as GDI+ goes, I’ve got:
CMainFrame::CMainFrame(){
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);}
CMainFrame::~CMainFrame(){
Gdiplus::GdiplusShutdown(m_gdiplusToken);}
in MainFrm.cpp. In the MainFrm.h public attributes:
ULONG_PTR m_gdiplusToken;
Should anything be somewhere else? The
#include <gdiplus.h>
is in the stdafx.h file.
Also, if I draw a rectangle over the image with a brush, how would I then erase the rectangle while redrawing/maintaining the background image (which currently crashes as stated above)?
Thanks
|
|
|
|
|