|
(1) Construct the CToolBar
(2) Create a toolbar resource
(3) Call Create() [pass the resource id]
(4) You prolly want to create it on a dialog. If so resize the dialog accordingly
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I try to create a toolbar in a dialog like this, but it not works.
BOOL CTempDlg::OnInitDialog()
{
...
...
m_toolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_NOALIGN))
m_toolbar.LoadToolBar(IDR_TOOLBAR1))
return TRUE; // return TRUE unless you set the focus to a control
}
Something wrong in my codes? In fact, I want to create a toolbar just in a CWnd, can I? "(4) You prolly want to create it on a dialog. If so resize the dialog accordingly", How to resize the dialog?
Thank u for your answer.
|
|
|
|
|
Hi there,
I'm working on webbrowser kind of application. I have a problem in open in new window part. I want to open the new link in the new frame of my mdi application. that part is done but i face the problem with popup windows. for that i need the exact dimention(height+width) of the popup window which is set in the script.
is there any way to get the exact size of the popup window?? i can get the height and widht usign get_Height and get_Width function of iwebbrowser2 interface but it doesnt give me the exact dimention all the times. in lot of popup windows it gives the wrong size.
if anybody knows the soln. pls help me out.
thanx in advance,
Paras Shah
|
|
|
|
|
First, does everyone use the wizards to start off a project. They seem a little annoying and create alot of code that is hard to follow.
And second, is there a simple little hello world program out there that uses MFCs
Cheers
|
|
|
|
|
Hope this helps...
Nish
#include "stdafx.h"
#include <afx.h>
#include <afxwin.h>
#include <afxext.h>
#include <afxdtctl.h>
CWinApp theApp;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
AfxMessageBox("somethin screwed up :-(");
nRetCode = 1;
}
else
{
AfxMessageBox("Cool, we are runnin on MFC");
}
return nRetCode;
}
|
|
|
|
|
Personally, I like to put all of those afx headers in my stdafx.h file. But that's just me being me.
|
|
|
|
|
yeah,
But I put them like that so he finds it easier to understand.
In this case stdafx.h contains only one line
#pragma once
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hey
I guess you mus have seen that there are some smilies in the other post. donno how to disable them
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Start with a dialog based app, there is a lot less to follow. Make the OnPain function in the dialog look like this:
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
dc.TextOut(10, 10, "Hello World");
CDialog::OnPaint();
}
I'm not sure if you need the call to the base class, so I left it in, although removing it appears to do no harm. There's your hello world, and the simplest MFC app you'll get outside of using MFC in a console app.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I don't know about everyone, but I always use wizards to begin my projects. They save a lot of time and get me going on the functionality right away. Like yourself, in the beginning I found it a bit hard to follow the generated code, but it was only a matter of time before I became familiar with it.
As far as a little Hello World program, again use the AppWizard to create a "Win32 Console Application". Then tell it you want to support MFC. Presto! See? I told wizards are great.
Regards,
Alvaro
|
|
|
|
|
first i'd like to ask if anyone here is a self taught vc6 programmer. as in no schools just books and stuff like that.
i'm finding that the prices for tuition at any school for a programming course is way out of my budget. i live canada so keep that in mind. next question:
gamedev says to start with a simple tetris like game to understand how a game is put together. i have a book that explains a breakout game and my logic tells me that programming a game like that would be easier then tetris. maybe i'm wrong. anyhoo could someone point me to some source files or code for a tetris like game so i could compare code and possibly understand.
i have to take the self taught book method.
|
|
|
|
|
You can teach yourself C++. In fact that's the only way I guess. Even if you have gone for some private course, you'd need to do a lot on your own in the way of self-teaching and books and MSDN and code-project before you can be a moderately competent C++ programmer
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I had one basic C++ course in school but for the most part I've learned though books and experience.
|
|
|
|
|
Yes, I'm completely self taught and everyone at work, although they went to uni, got there knowing a lot from teaching themself. To survive in IT you need to *keep* learning your entire career, so if you can't teach yourself, you're kinda screwed.
I believe that there is a Tetris game here on CP. Yes, Pong is probably easier still, although not by much. Calculating the bounce of the ball convincingly is probably more painful than figuring if a Tetris block fits in a certain space.
A game is always a big thing to start with though, you need graphics, you need sound, you'll probably want to use DirectDraw, etc. You're better off IMO trying some non game stuff first. To give you an idea, I did a fair bit of non-game stuff to learn and when I did try a game, I was able to do a reasonable Asteroids. Had I started with that, I'd probably have given up in despair, but I kenw how a lot of other stuff fit together so I was able to concentrate on graphics and physics.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I'm a self taught programmer. However I had the easier route of moving from Sinclair Basic, to Turbo Pascal, to Turbo C, to Borland C++ and then onto Visual C++. It is a lot easier if you start at the bottom, sadly that isn't so easy nowadays. I remember my early days of the move from Pascal to C. C was a very scary language to me back then.
My advice, stick with the breakout program. Breakout is a much simplier app than Tetris. However learning to program by writing a game is very difficult, especially a Windows game if DirectX is involved.
Feel free to ask questions though, that is the best way to keep on learning.
Michael
|
|
|
|
|
If you want to start with C++ start with Sams Teach Yourself C++ in 24 Hours Second Edition. For game programming I would look for a Tearch Yourself DirectX. Another good book that teaches MFC is Teach Yourself Visual C++ 6 in 21 Days. If you can find it look for Game Programming Starter Kit from Macmillan Software 4.0 gives you VC++ in 21 and DX in 24 but 5.0 is the current version. It also has some game programming tools.
-Matt Newman
-Matt Newman
|
|
|
|
|
|
You send/post WM_CLOSE to a window when you want to close it. Normally the WM_CLOSE handler then calls DestroyWindow which sends a WM_DESTROY message to the window. later the WM_NCDESTROY message is sent. This is the last message that window receives
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I use WM_CLOSE to ask the user if they want to save the document they are working on. If they click cancel I don't call DestroyWindow and the program returns to its previous state. I use WM_DESTROY to release all my resources.
|
|
|
|
|
I am creating a utility that does not have a main window. I show different dialogs, one after the other, depending on the situation. It seems the 1st put up dialog gets to be the taskbar button. I would like the next dialog to get its own taskbar button, but I can't figure out how to do it.
Please enlighten me,
Cathy
Cathy
|
|
|
|
|
|
Thanks, but I already tried that with no luck. I changed it in the .rc file. Was that the correct place?
Cathy
|
|
|
|
|
I want to get the title of Internet Explorer:
#include <windows.h>
LPSTR strIE;
LPSTR str2;
HWND IE;
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
IE = FindWindow("IEFrame",NULL);
if( IE != NULL )
{
GetWindowText(IE, strIE, GetWindowTextLength(IE));
MessageBox(NULL, (LPCTSTR) strIE,"",MB_OK);
}
return 0;
}
But no MessageBox(...) at all will appear!
What is wrong?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
The problem is that your whole app should be exploding. You haven't actually allocated any memory for your string, so the behavior will certainly be unexpected. Try allocating enough space for the string first then calll GetWindowText passing in the amount of space you actually allocated then do the message box then remember to clean up the memory you allocated. A good start would be to learn C/C++ programming before jumping head first into windows development.
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Since the IEframe does not belong to your app's process you need to send the WM_GETTEXT message to the hwnd of the IE. This is the correct way:
TCHAR wndText[512];
::SendMessage(IE,WM_GETTEXT,sizeof(wndText)/sizeof(TCHAR),(LPARAM)(void*)wndText);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|