|
here is the code if it helps:
pDC->SetTextColor(Color);
pOldFont = pDC->SelectObject(&m_TextFont);
pDC->TextOut(m_StartPoint.x, m_StartPoint.y, m_String);
pDC->SelectObject(pOldFont);
|
|
|
|
|
My question is, does anyone have an example of code that would mimic the group selection functionality of the Power Point type applications using DrawDragRect or some other function?
I'm trying to use the DrawDragRect() function in my app for group selection purposes much like in Power Point, etc... I want to be able to traw the rectangle and stretch it to enclose certain objects in my view. I'm using the function and I'm using the Halftone brush. I understand how that works with the background and foreground colors and all. My question, though, is in regards to the brush used when drawing the rectangle. When I start to draw the rectangle, the view is shown completely in the halftone brush format (Dithered) and the inside of the rectangle is drawn transparent only when it is dragged from the bottom right of the screen to the top left of the screen.
|
|
|
|
|
I already know how to do windows programing using only the win 32 api. Now I am learing Visual C++ .NET. How easy is it to mix the two?
For instance could I create a dialog box class with VC++ and then use it in a win 32 api program?
Are there any potential problem of which I should be aware?
Would it be better to create the dialog box as a dll?
|
|
|
|
|
|
Actually I am more interested in calling MFC from a win 32 api application.
For example if I wrote a game, I would want to use win 32 api for everything except the dialog boxes which would be done with MFC.
Can I just add the files that define dialog boxes to my win 32 project and then use them the same as I would from MFC?
Or would I have to create a MFC project and then use the win 32 api calls to create the main window?
Would creating the MFC Dialog as a DLL help?
|
|
|
|
|
You're confusing several things. Visual C++ is not a language, it's the development environment. When you make a dialog with the VC resource editor, it doesn't restrict you to any particular flavor of C++, whether it's straight APIs, MC++, etc.
.NET and MFC are class libraries. .NET (from my second-hand knowledge of it) is pretty much a complete abstraction layer away from the Win32 API, whereas with MFC you can (and will!) use a lot of your API knowledge.
As for mixing, you can freely mix straight APIs, ATL, WTL, and (with the right compiler settings) MFC. You can also mix managed and normal code with VC.NET, although you can use .NET only in managed code.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I understand that Visual C++ is a collection of classes (MFC) and Wizzard that automate the construction of those classes. And I know that you can use the win 32 api functions from MFC.
What I didn't know till now is whether I can take a win 32 api project and then inport MFC classes as needed.
For example if I write a game I would want it to be a win 32 api application because MFC is too inefficient and inflexible for serious game programing. (Plus I hear it doesn't play nice with Direct X and possible Open GL). But I would like to use MFC for setting and what not.
What compiler setting would I need to add an MFC dialog box to a win 32 api application?
|
|
|
|
|
Hi all,
I'm looking for a training project that can help me to learn C++ more easily and also efficiently.
Please let me know if you have any good training project in mind or any website that I can find C++ training project. Thanks in advance.
|
|
|
|
|
beginner-beginner level: simple console application to print out say, the fibonacci sequence
intermediate-beginner level: a console app to apply simple encryption to a raw data stream from a binary file ("somefile.dat") and output it to ("outfile.dat") then revert it back
expert-beginner level: a console app to parse a mathematical function expression string (e.g. "sqrt(9) + 5 ^ x * 2.1 + 1") and print out the result
just some suggestions
- Roman -
|
|
|
|
|
Hi all,
I'm looking for a training project that can help me to learn C++ more easily and also efficiently.
|
|
|
|
|
Personally I like the Teach Yourself ... in 21 Day Books when learning a new language or skill, hopefully one available at the local libray. After each lesson it suggests execises that you can do on your own.
(Then I usually purchase a reference manual and read that cover to cover.)
If you looking for something a larger more complex then you really should dream something up yourself.
I usually keep a notebook where I write down ideas for projects as they occur to me. Usually the projects fall into these categories.
1) Projects that Apply recently learned knowledge, but are otherwise useless. I recently wrote a win 32 api application that uses a dilog box to get parameters and then draws various 2d Primatives. Why, because I just finished Reading "Windows 98 Programming From the Ground Up" and am studying graphic algorithms form "Computer Graphics Principles And Practice". I try to do at least one project for each book I read.
2) Small Utilities and Tool for personal use. I am brushing up on my typing and the program I am using allows me to import my own text, but always starts at the beginning. So I am writing a program that breaks a text file into numbered files of the desired length to use when I practice typing. Any busy work you find yourself doing repeatedy on your computer is a good.
3) Improvements on existing programs. Sometimes a program I am using just doesn't work the way I want it to. For instance I recently downloaded a bunch of vocalubary tutouring programs and all of them had serious flaws. So now one of my potential projects is to write a my own vocabulary program.
4) Games. Games always make fun projects. VC++ is not the ideal environment for hard core game programming, but there is no reason why you could not make a decent 2d game. Plus games are about the only projects that will impress your non-programmer friends. Same goes with screen savers.
Pick something that interest you that is within or slightly beyond your capabilities.
Everyone should read Code Complete by Steve McConnell. Reading this book has easily doubled the quality of my code.
|
|
|
|
|
Hi, all
In Atl project ,how can I return the user define type?
For example , I have define a Struct ,and I want to return the Struct type in a function, and I plan to utilize the return Struct type in VB through the com. What should I do ? I have try some ways ,but failed.
Another similar problem. I have two ATL Object in my Atl
project , Teacher and Student . And student is a private property of Teacher ,now I want to construct a function in Teacher to return the Student property .How should I do ?
Sincerely ask for help. Who can tell me how to do , or give me some similar source code which resovle the above problems .
I'll appreciate it .
Regards.
|
|
|
|
|
In the IDL file do the following:
typedef struct
{
int x;
int y;
} POINT;
interface IMyInterface : IUnknown
{
[propget, helpstring("property Point")] HRESULT Point([out, retval] POINT *pVal);
Note that the iterface inherits from IUnknown (Custom interface) and not from IDispatch (Dual interface).
Goodluck,
Dudi
|
|
|
|
|
And how can I construct the CStudent object in CTeacher.
Details as follows.
In the construction function of the CTeacher :
CTeacher()
{
IStudent * m_student =new CStudent();
return;
}
There are some compiler errors. It says that the CStudent cannot instantiate abstract class due to following members:QueryInterface,AddRef,Release.
How should I do to resolve the problem.
thx.
Regards.
|
|
|
|
|
You cannot create a com object by using new.
Use CComObject instead:
CComObject<CStudent> *m_student;
HRESULT hr = CComObject<CStudent>::CreateInstance(&m_student);
|
|
|
|
|
Hi, all
Some problems about ATL Com:
1.I have create two ATL Object: CStudent and CTeacher .
The simple source code listed as follow: (some code auto generated by ATL have been skiped)
class CStudent
{
private:
long m_age;
public:
CStudent():m_age(10)
{
}
//...other code auto generated by ATL
};
class CTeacher
{
private:
IStudent* m_aStudent;
public:
CTeacher()
{
//create an instance of the com
CoCreateInstance(CLSID_Student,NULL,CLSCTX_ALL,IID_IStudent, (void**)&m_aStudent);
}
//...other code auto generated by ATL
}
2.Then I add a "IStudent * OneStudent" property for ITeacher ,to access the m_aStudent.
The implemention of the property are listed as below:
STDMETHODIMP CTeacher::get_OneStudent(IStudent *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = * m_aStudent;
return S_OK;
}
STDMETHODIMP CTeacher::put_OneStudent(IStudent *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*m_aStudent = *newVal ;
return S_OK;
}
3.Now I type some VB code to test the com ,but some compiler errors occurrs.
VB Code:
Dim s As Student
Dim t As New Teacher
s = t.OneStudent
the last sentence "s = t.OneStudent" have compiler errors.
Errors:function or interface marked as restricted ,or the function use an Automation type not supported in Visual Basic
I guess the errors caused by the type dismatch between IStudnet and CStudent.But I did not know how to resolve it .
So who can tell me how to return the m_aStudent that can be supproted in vb??
thx.
Regards.
|
|
|
|
|
In VB you should write
set s = t.OneStudent.
Now, you don't support 'get' function but 'put' function.
This is why VB send you that error.
Add the following:
STDMETHODIMP CTeacher::get_OneStudent(IStudent **pVal)
{
// put your code
return S_OK;
}
you should change the IDL file, as well.
Goodluck,
Dudi
|
|
|
|
|
1. At a late stage in the evolution of my MDI CFormView based GUI development I am told that my GUI must access a database. Now i didnt build in db support at the start of the project. Surely this doesnt mean I start over again?
2. I have some books that talk of DAO and MFC. It was mentioned I should use ADO but I cannot find any thing about it - like samples etc.
3. In a sample project I have using DAO, they have to use the Class Wizard to create a new recordset class derived from CDaoRecordSet. The CW then points you to the mdb file on the disk and you choose tables etc. Now I'll be needing to do this stuff dynamically, ie. if the user specifies a db name during runtime, I need to automate the process of creating the recordset class. My database is a flat file with the fields being keywords, and the rows being the records and the entries in the "matrix" being the values of these keywords.
according to this sample project -"the CW will prompt you for which table(s) to include in the record set class. The CW then creates the recordset and you see that there is a member variable in this class for each column in the table you selected. "
So here my question is, I will be doing this for diffferent databases with different # of fields, and how do I create the recordset in code instead of manually through the CW.
I am just starting to investigate the notion of databases so I will have tons more questions, and hope these above aren';t confusing. I really appreciate your response,
thanks,
ns
|
|
|
|
|
|
You know, rihjt after I posted these questions, I got the brilliant idea of checking out CP and viola! a wealth of info answering some of my questions, though more will follow shortly without a doubt. SO thanks!! The rest of the web seems to have nothing with a google search of database, ADO and MFC.....unless i'm doing a poor search.
Thanks,
ns
|
|
|
|
|
I'm trying to add HTMLHelp support to my application. I can create HTMLHelp and have the proper libraries linked in but I don't understand how to set the HH_POPUP parameters for use in the HtmlHelp() function.
In my OnHelpInfo(HELPINFO* pHelpInfo) event, I normally use...
AfxGetApp()->WinHelp(pHelpInfo->dwContextId, HELP_CONTEXTPOPUP);
I'm replacing it with...
HH_POPUP popup;<br />
HtmlHelp(GetSafeHwnd(), NULL, HH_DISPLAY_TEXT_POPUP, (DWORD)&popup);
How should I set the values for popup ?
|
|
|
|
|
i can use isapi op a Cookie,but,how i can op a session?
please help me,
ths!!!
if you have code,tell me!
ths again
|
|
|
|
|
I guess that depends on what "op" means?!...
"After all it's just text at the end of the day. - Colin Davies
|
|
|
|
|
Is it possible to get the main window which associated with an instance handle? Or there's no such association?
Any help will be personally blessed!
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|