|
don't start with a "Win32" app. that's the low-level, old-school, messaqge-loop and Win32 API stuff.
i'd start with an MFC "Dialog App". MFC is much friendlier than Win32.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hi Chris,
Thanks for the response.
I (very quickly) started an MFC project. The default gui had default icons like that of mfc based wordpad. Can you build applications that do not contain these defaults?
Without asking to much of you, are there any disadvantages of using MFC over Win32 api. I have yet to find a good explanation of which is good / bad etc.
Many thanks
Dave
|
|
|
|
|
Hello,
If you start the wizard for a new MFC project, you can select different kinds of options all the time. If I remember correctly, It's the second dialog where you can select if you want a dialog based application, and SDI or MDI application. You selected SDI (the default) and the results is the default implementation to get you started. (With pure WIN32 it would have taken you a few days to get it!)
You should select the dialog based option to get the forms you want.
Good luck.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
(i assume you're using VS'03)
start a new MFC project. in the Application Type tab, choose dialog. the "Wordpad" stuff is probably an SDI (Single Document Interface) app. that's a bit more complicated that a dialog app, if you're new to MFC. once you have your blank dialog, you can drop controls onto it and play with messages kindof like you do in VB.
if you use the Win32 API, you're going to have to get intimately familiar with Windows' message passing and handling. these days, the only real benefit from a Win32 app over an MFC app is that the Win32 app won't require MFC (which adds size to the EXE - roughly 200K for a dialog app - no big deal). other than that, MFC is the way to go.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hi again.
Thanks very much for the responses. I understand alot more now. MFC looks like the way to go then
I am sure I will be back shortly with MFC related questions In the meantime thanks everyone for the feedback.
Dave
|
|
|
|
|
I learned the basics at functionx.com, more specifically in their Visual C++ section. Start looking under the "How-To" section on the right side. They teach you how to create a project, create dialog boxes, call them in the code when you press a button, transfer information from the dialog box back to the program, etc... Once you understand that, then you can look to the left side under "Windows Controls" and learn how each standard windows control works. The "MFC Fundamentals" above it is also very helpful to learn next. If you understand all of that, then you can understand all the articles here and can begin work.
The biggest hurdle programmers have (and that I had) is first, understanding that with console apps, the programmer guides the action completely. In MFC applications, the mechanics of the program are already written for you when the AppWizard creates your project, but you, the programmer, need to program what should be done when certain events occur.
For example, if you create a button and add an event handler, Visual Studio will change the mechanics of your project and add a function that will be run when the button is pressed. All you have to do is to write code in that function that should be run when the button is pressed.
I learned MFC basics on functionx.com but I came here because there's much more information but it's only useful if you are somewhat familiar with MFC. Good luck in your studies.
|
|
|
|
|
I havejust begun to program, but only minor things. Mostly i read about sites for help but they just confuse me. Even the beginner C# tutorials here confuse me. This is mostly because of the words and the format. Some expect you to be already familiar with C++, and i am not. If someone could give me some advice of a site to go to, or any information that could possibly help me progress in the ways of C#.
I never think of the future.It comes soon enough
**Albert Einstein**
|
|
|
|
|
Monkey De Lufy: Pirate King wrote: If someone could give me some advice of a site to go to, or any information that could possibly help me progress in the ways of C#.
See here.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello All,
I am using visual studio .net 2003 c++.
I am trying to get my datagrid to auto resize its columns automatically
using the following code from:
www.hanselman.com/blog/PermaLink.aspx?guid=f3e94fab-335d-497f-8340-9c4ae8e02fa3"
This is his take on the subject and how to do it:
If you double click on the little splitter between columns they will autosize. Therefore, the code to autosize has been written for me; no need to measure strings, etc. How do I force a double click? No, wait, wrongheadedness, how do I call whatever THEY call when a double click happens? So, I reflectored into DataGrid.OnMouseDown and saw their custom HitTest calls a private ColAutoResize.
private void dgLogging_DataSourceChanged(object sender, System.EventArgs e)
{
try
{
Type t = dgLogging.GetType();
MethodInfo m = t.GetMethod("ColAutoResize",BindingFlags.NonPublic);
for (int i = dgLogging.FirstVisibleColumn; (i <
dgLogging.VisibleColumnCount); i++)
{
m.Invoke(dgLogging, new object[]{i});
}
}
catch (Exception ex)
{
System.Diagnostics.Trace.Write("Failed Resizing Columns: " + ex.ToString());
}
}
To tell you the truth I have been away from programming for over a year and I was using viusual c++ 6 at that time so .net is new to me and sure don't understand reflection that well. As to the statement above "So, I reflectored into DataGrid.OnMouseDown and saw their custom HitTest calls a private ColAutoResize."
I don't understand how I can find this method. What I have done is entered this code in order to see all the methods in my datagrid and can find nothing on ColAutoResize.
Type* typ = this->dataGrid1->GetType();
MethodInfo* mi[] = typ->GetMethods();
int MethodCount = mi->Count;
for (int i = 0; i < MethodCount; i++)
{
listBox1->Items->Add(mi[i]->Name);
}
By the above statement,"So, I reflectored into DataGrid.OnMouseDown and saw their custom HitTest calls a private ColAutoResize."
Can someone tell me if I'm looking in the right place for this method or how
I can reflector into DataGrid.OnMouseDown.
Thank You.
RSW
|
|
|
|
|
Hi
Please could someone help me to convert the following to Visual Basic.. It is a CRC16 algorithm using the polynomial (x16 + x15 + x2 + 1) used for very short strings.
Tks
Richard
static unsigned BitsSet (unsigned char ch)
{
unsigned n;
n = 0;
while (ch)
{
n += (ch & 1);
ch >>= 1;
}
return(n);
}
unsigned CRCof (const char *message, unsigned len)
{
unsigned i;
unsigned crc;
unsigned char k;
crc = 0;
for (i=0; i<len; i++)
{
k = (unsigned char)(message[i]) ^ crc; crc = (crc / 256) ^ (k*128) ^(k*64);
if ((BitsSet(k) & 1) != 0)
crc ^= 0xC001;
}
return(crc);
}
|
|
|
|
|
I have an Intenet Explorer toolbar and I want to display a bitmap on it. I used the button separator to make room for the control in the toolbar and I can display text in the CStatic, but when I try to display an image the whole CStatic is painted with a single color. I think it is the first pixel color of the bmp.
I use the following code:
//in the header file:
<br />
CStatic anonTitle;<br />
//in the cpp file
<br />
anonTitle.Create("",WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE, rcTitle,this));<br />
<br />
CBitmap anonPic;<br />
anonPic.LoadBitmap(IDB_BITMAP3);<br />
anonTitle.SetBitmap((HBITMAP)anonPic.m_hObject);<br />
anonPic.Detach();<br />
If I use the code from a MFC application it works. But in the toolbar the whole static is painted with only one color.
I have also tried with :
<br />
anonTitle.Create("",WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE, rcTitle,this));<br />
anonTitle.SetBitmap( ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BITMAP3)));<br />
and
<br />
CString str;<br />
str.Format(_T("#%d"), IDB_BITMAP3); <br />
anonTitle.Create(str,WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_CENTERIMAGE, rcTitle,this));<br />
and still same result.
Desperate help needed.
Best regards,
Mircea
Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.
|
|
|
|
|
class AAA
{
public:
virtual int test()=0;
virtual ~AAA(){std::cout<<"~AAA"<<std::endl;}
protected:
private:
};
class bbb
{
public:
="" virtual="" int="" test()="0;
//If" the="" destructor="" is="" not="" virtual,="" there="" a="" runtime="" error="" which="" will
="" terminate="" program.
="" i="" don't="" know="" why,="" though="" wrong="" called.
="" ~bbb(){std::cout<<"~bbb"<<std::endl;}
protected:
private:
};
class="" ccc="" :="" public="" aaa,public="" {return="" 1;}
="" ~ccc(){std::cout<<"~ccc"<<std::endl;}
protected:
private:
};
int="" main(int="" argc,="" char*="" argv[])
{
="" bbb="" *pbbb="new" ccc;
="" std::cout<<pbbb-="">test()<
|
|
|
|
|
|
I'm sure that you have a question of some degree in relation to the code you posted. I figure that you have a question about virtual destructors in relation with multiple inheritance, but please hint me, where is your question?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
The question is hidden in one of the comment ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I generally skip illustrations until I've read the question..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote: but please hint me, where is your question?
as his question was hidden, i was also asking for it with criticism and "hidden style" too
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I think that people should take more time to post a clear question, instead of hiding it in something that is supposed to be an inllustration.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Why will the program be aborted, when ~BBB() is not virtual?
|
|
|
|
|
Hello,
I think that when the runtime destroys your object, it sees that it is instantiated from multiple classes (the inheritance). The runtime then starts to look for all appropriate destructors in the virtual function table. This is done because the runtime must call more than one destructor. When the runtime detects that one of the destructors is 'missing' in the v-tables, it crashes since it doesn't know what to do.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Yeah, if you don't have virtual destructors, then your delete better be to a pointer of the proper class allocation.
For example, with ~BBB non-virtual, this will not crash:
CCC* pbbb = new CCC;<br />
delete pbbb;
So, if you can't afford virtual destructors, then you better cast your delete operation to a pointer of the correct type.
For example, with ~BBB non-virtual, this DOES NOT crash:
BBB* pbbb = new CCC;<br />
CCC* pccc = (CCC*)pbbb;<br />
delete pccc;
|
|
|
|
|
Hi
Please could someone help me to convert the following to Visual Basic.. It is a CRC16 algorithm using the polynomial (x16 + x15 + x2 + 1) used for very short strings.
Tks
Richard
static unsigned BitsSet (unsigned char ch)
{
unsigned n; n = 0;
while (ch)
{
n += (ch & 1);
ch >>= 1;
}
return(n);
}
unsigned CRCof (const char *message, unsigned len)
{
unsigned i;
unsigned crc;
unsigned char k;
crc = 0;
for (i=0; i
|
|
|
|
|
When you click on a Dialogs title bar what event is triggered? How does one detect if the title bar has been clicked?
thanks,
sb
|
|
|
|
|
WM_LBUTTONDOWN is sent for sure, maybe WM_NCHITTEST ca nbe intercepted (check for OnNcHitTest whose return value is HTCAPTION when the title bar was clicked). To be sure, try with Spy++,
~RaGE();
|
|
|
|
|
I am creating an edit control like this .....
editPointSize.Create(ES_CENTER|WS_VISIBLE|WS_CHILD,rectOffScreen, this, ID_EDIT_POINT_SIZE);
Then I am setting up the text in it like this .....
CString strData;<br />
strData.Format("%d", nPointSize);<br />
editPointSize.SetWindowText(strData);
If I run this under the debugger its OK, but if I compile and run a release version it crashes, any ideas?
Many Thanks,
Ali
|
|
|
|