|
MAINFRM
<br />
<br />
#include "stdafx.h"<br />
#include "Scribble.h"<br />
<br />
#include "MainFrm.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)<br />
<br />
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)<br />
ON_WM_CREATE()<br />
END_MESSAGE_MAP()<br />
<br />
static UINT indicators[] =<br />
{<br />
ID_SEPARATOR,
ID_INDICATOR_CAPS,<br />
ID_INDICATOR_NUM,<br />
ID_INDICATOR_SCRL,<br />
};<br />
<br />
<br />
CMainFrame::CMainFrame()<br />
{<br />
<br />
}<br />
<br />
CMainFrame::~CMainFrame()<br />
{<br />
}<br />
<br />
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
if (!m_wndToolBar.Create(this) ||<br />
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))<br />
{<br />
TRACE0("Failed to create toolbar\n");<br />
return -1;
}<br />
<br />
if (!m_wndStatusBar.Create(this) ||<br />
!m_wndStatusBar.SetIndicators(indicators,<br />
sizeof(indicators)/sizeof(UINT)))<br />
{<br />
TRACE0("Failed to create status bar\n");<br />
return -1;
}<br />
<br />
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |<br />
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);<br />
<br />
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);<br />
EnableDocking(CBRS_ALIGN_ANY);<br />
DockControlBar(&m_wndToolBar);<br />
<br />
<br />
return 0;<br />
}<br />
<br />
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
<br />
return CMDIFrameWnd::PreCreateWindow(cs);<br />
}<br />
<br />
<br />
#ifdef _DEBUG<br />
void CMainFrame::AssertValid() const<br />
{<br />
CMDIFrameWnd::AssertValid();<br />
}<br />
<br />
void CMainFrame::Dump(CDumpContext& dc) const<br />
{<br />
CMDIFrameWnd::Dump(dc);<br />
}<br />
<br />
#endif //_DEBUG<br />
<br />
<br />
<br />
class CMainFrame : public CMDIFrameWnd<br />
{<br />
DECLARE_DYNAMIC(CMainFrame)<br />
public:<br />
CMainFrame();<br />
<br />
public:<br />
<br />
public:<br />
<br />
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);<br />
<br />
public:<br />
virtual ~CMainFrame();<br />
#ifdef _DEBUG<br />
virtual void AssertValid() const;<br />
virtual void Dump(CDumpContext& dc) const;<br />
#endif<br />
<br />
protected:
CStatusBar m_wndStatusBar;<br />
CToolBar m_wndToolBar;<br />
<br />
protected:<br />
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Hi!!
I am using slider control in my application.
I set JPG image as background for my dialog using CXImage.
How Can I set transparent to slider control background.
Can anyone please give me the solution for this...
Thanks&Regards,
klvin
|
|
|
|
|
Can you try this ?
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (CTLCOLOR_SCROLLBAR == nCtlColor)
{
pDC->SetBkMode(TRANSPARENT);
}
return hbr;
}
|
|
|
|
|
Hi !!
Thanks for the reply.
I tried with OnCtlColor(...)
But,It is not working.
klvin.
|
|
|
|
|
Why the constructor, destructor and copy constructor in c++ are not able to inherit by the derived class. And what else cannot be inherited from the derived class
|
|
|
|
|
Seems you are new to OOPs... stydy something(books, web page...) to know basic of OOP.
Do your Duty and Don't expect the Result
|
|
|
|
|
it;s no necessary...
|
|
|
|
|
Hi all.
I am using a Microsoft web browser to show the preview of web pages available in my application. This web browser is a part of a Modal Dialog box. I am loading those html pages from the specific location.
As this web browser control is a part of dialog box I can't make its size too big to show complete web page. As a result when I load the html page in it, the scroll bars appears for browser control.
What I want is to resize my html pages according to the size of the browser control so that user will not be required to scroll to have a complete view of the web page.
So how can I resize the html pages before loading them in the browser control?
OR
Is there any other way to do this?
Thanks
Rakesh Thakur
|
|
|
|
|
Rakesh_Thakur wrote: I am loading those html pages from the specific location
Since you are loading a page, i think its not possible to avoid the scroll bars. Other wise you modal dialog has to be resized.
(OR)
If you have the web page details as image file, you can resize the image.
Do your Duty and Don't expect the Result
|
|
|
|
|
Hi.
Can anyone give me a simple example of how to create an iterator for one of your own classes?
I have a binary Search Tree ADT (BST.cpp) that can insert, delete and traverse the binary search tree in sorted order.
The inorder traversal should use the operators from the STL bidirectional iterator.
My BST should provide appropriate, efficient iterators that can be given to any of the STL generic algorithms. My BST should look and feel like an object not just a wrapper around existing C code.
Any hints or small examples that can help me out, will be greatly appreciated.
Thanks.
|
|
|
|
|
|
Hello,
Edit is derived from class CEdit
int i=0;
vector<Edit*>R;
Edit *p;
p = R[i];
p->SetFocus();
I want to move from one edit box to another which I am able to do.I go from one edit box to another by i++ or i-- depending on the key pressed.and calling the function
R[i]->SetFocus();
But when I click the mouse I am not able to move the focus to the clicked edit box.How should I do it?
In what way should I define a pointer so that I acheive the move ?
Prithaa
|
|
|
|
|
prithaa wrote: when I click the mouse I am not able to move the focus to the clicked edit box.How should I do it?
the edit box will get its focus automatically.. there is nothing special to set its focus while clicking on it...
Do your Duty and Don't expect the Result
|
|
|
|
|
can't you use the tab key to navigate through the controls ?
|
|
|
|
|
Are the edit controls on a dialog? If so, you should use something like this to properly
move focus to the control:
int i=0;
vector<edit*>R;
Edit *p;
p = R[i];
GotoDlgCtrl(p);
prithaa wrote: But when I click the mouse I am not able to move the focus to the clicked edit box.How should I do it?
You shouldn't have to do this yourself. When you click in the edit box do you get the caret?
If so, then it has the focus. If you are trying to set the focus yourself on a mouse click
then you may be preventing it from getting focus.
Mark
|
|
|
|
|
I have a class that I wrote I C# and I want to use it in a VC++ project without turning the C# class into a COM object. These are the steps that I've been given by a colleague:
I don't have code sample but I have steps how to do it. But my problem is how do I do step 9? Does anyone have a code sample of how to access the C# methods in VC++ through a type library??
Much appreciated!
L
1. Create a C# class
2. Generate a key for it - sn -k keyfile.snk
3. Put an assembly directive at top of file
[(Assembly: AssemblyKeyFile("keyfile.snk")]
4. Compile
5. regasm file.dll /tlb to generate the COM Type Library
6. gacutil -i file.dll to place file in GAC
7. Copy the generated typelibraries into the directory of your ATL/C++ project
8. #import file.tlb no_namespaces named_guids (look up the reff for exact syntax)
9. Compile ATL/C++ code and you will have access to the interfaces through the types in the imported tlb
|
|
|
|
|
Step 9 is just accessing the C# calls as if they were any COM object. They have nothing to do with C#.
So long as your project depends on the .NET framework, turning on C++/CLI or Managed C++ seems a more sensible and easier option to me.
Christian Graus - C++ MVP
|
|
|
|
|
Actually I'm going to have to use this C++ dll as a 'bridge'. I'm going to have to use it to implement an abstract interface defined outside managed code, and make calls to the managed C# dll to call certain methods to help the 'bridge' implement the interface.
What is the actual syntax of it? I'm having some trouble finding examples.
Sorry if any of these questions are ignorant, I'm a newbie to C++/COM programming.
If I were to access the C# methods as any COM object would I need to use cocreateinstance?
|
|
|
|
|
malayalite wrote: If I were to access the C# methods as any COM object would I need to use cocreateinstance?
No, having called #import, you shoud have smart pointers at your disposal. Change the #import statement to specify a namespace (get rid of the no_namespaces and find the syntax to specify one ), then intellisense will show you the rest. From memory, if you have a class called MyClass, you end up with MyClassPtr. But, that's very rusty memory, indeed.
Christian Graus - C++ MVP
|
|
|
|
|
Ok cool that seems to have done the trick.
Thanks! I really appreciate it.
|
|
|
|
|
about VC+MySQL problem
i install mysql odbc V5.0 driver
i need to ADO Connect MYSQL DB;
code:
_ConnectionPtr m_CMConnect;
::CoInitialize(NULL);
m_CMConnect.CreateInstance(__uuidof(Connection));
m_CMConnect->Open("Provider=MySQL;server=localhost;DataBase=test;port=3306;uid=root;pwd=","","",-1);
but Program run error.....
how to Ado Connect MYSQL DB;
thank
Blog:
http://360.yahoo.com/rxgmoral
|
|
|
|
|
rxgmoral wrote: ::CoInitialize(NULL);
Shouldn't this go first ? What's the error ?
Christian Graus - C++ MVP
|
|
|
|
|
Hi everyone!
I'm having trouble reading data from a text file. More specifically, I'm trying to read a function of two parameters from a text file and then pass it to an array of functions of two parameters.
This is what I have so far:
TextFile1.txt:
1+x*x+t*t*t 1.0 0.0 -4.0
Input.h:
#include <iostream><br />
#include <fstream><br />
using namespace std;<br />
void fin (double** (*f)(double, double), double* a, double* b, double* x, char* fin)<br />
{<br />
ifstream file (fin);<br />
file >> f[0] >> a[0] >> b[0] >> x[0];<br />
}
Problem 7 Ode.h:
#include <cmath><br />
#include <iostream><br />
using namespace std; <br />
const double lambda = - 50;<br />
const int n = 20;<br />
class ode<br />
{<br />
double tini;<br />
double ison;<br />
double tend;<br />
double (*sfn)(double t, double x);<br />
public:<br />
ode(double t0, double x0, double T, double (*f) (double t, double x)) <br />
{<br />
tini = t0;<br />
ison = x0;<br />
tend = T;<br />
sfn = f;<br />
} <br />
double* rungekuttaforward (int n) const;<br />
double* rungekuttabackward (int n) const;<br />
};<br />
double* ode::rungekuttaforward (int n) const<br />
{<br />
double* x = new double [n + 1];<br />
double * t = new double [n + 1];<br />
t[0] = tini;<br />
double h = (tend - tini) / n;<br />
x[0] = ison;<br />
for (int i = 0; i <= n; i++) <br />
{<br />
double K1 = h * sfn (t[i], x[i]);<br />
double K2 = h * sfn (t[i] + h/2.0, x[i] + K1/2.0);<br />
double K3 = h * sfn (t[i] + h/2.0, x[i] + K2/2.0);<br />
double K4 = h * sfn (t[i] + h, x[i] + K3);<br />
x[i+1] = x[i] + (K1 + 2.0 * K2 + 2.0 * K3 + K4) / 6.0;<br />
cout << "i = " << i << " " << "t = " << t[i] << " " << "x = " << x[i] << "\n";<br />
t[i+1] = t[i] + h;<br />
}<br />
return x;<br />
}<br />
double* ode::rungekuttabackward (int n) const<br />
{<br />
double * x = new double [n + 1];<br />
double * t = new double [n + 1];<br />
t[n + 1] = tini;<br />
double h = (tend - tini) / n;<br />
x[n + 1] = ison;<br />
for (int i = n + 1; i >= 1; i--)<br />
{<br />
double K1 = h * sfn (t[i], x[i]);<br />
double K2 = h * sfn (t[i] + h/2.0, x[i] + K1/2.0);<br />
double K3 = h * sfn (t[i] + h/2.0, x[i] + K2/2.0);<br />
double K4 = h * sfn (t[i] + h, x[i] + K3);<br />
x[i -1] = x[i] + (K1 + 2.0 * K2 + 2.0 * K3 + K4) / 6.0;<br />
cout << "i = " << i << " " << "t = " << t[i] << " " << "x = " << x[i] << "\n";<br />
t[i -1] = t[i] + h;<br />
}<br />
return x;<br />
Problem 7.cpp:
<br />
#include "Problem 7 Ode.h"<br />
#include "Input.h"<br />
#include <iostream><br />
using namespace std;<br />
void (**f[1])(double, double);<br />
int main()<br />
{<br />
double a[1];<br />
double b[1];<br />
double x[1];<br />
char *f_in = "TextFile1.txt";<br />
fin (f, a, b, x, f_in);<br />
ode part2(a[0], x[0], b[0], f[0]);<br />
double* soln2 = part2.rungekuttaforward (n);<br />
double h = (b[0] - a[0]) / n;<br />
}
This is what I get when I try to run the program:
------ Rebuild All started: Project: Assignment 4 - Problem 7, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'Assignment 4 - Problem 7', configuration 'Debug|Win32'
Compiling...
Problem 7.cpp
c:\documents and settings\jessica ann quan\my documents\visual studio 2005\projects\assignment4\assignment 4 - problem 7\input.h(11) : error C2109: subscript requires array or pointer type
c:\documents and settings\jessica ann quan\my documents\visual studio 2005\projects\assignment4\assignment 4 - problem 7\problem 7.cpp(25) : error C2664: 'fin' : cannot convert parameter 1 from 'void (__cdecl **[1])(double,double)' to 'double **(__cdecl *)(double,double)'
There is no context in which this conversion is possible
c:\documents and settings\jessica ann quan\my documents\visual studio 2005\projects\assignment4\assignment 4 - problem 7\problem 7.cpp(27) : error C2664: 'ode::ode(double,double,double,double (__cdecl *)(double,double))' : cannot convert parameter 4 from 'void (__cdecl **)(double,double)' to 'double (__cdecl *)(double,double)'
There is no context in which this conversion is possible
Assignment 4 - Problem 7 - 3 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Any tips or insight in how to get this to run properly would be greatly appreciated!
Thanks!
|
|
|
|
|
ummmmm...
The problem starts at the top, in input.h.
The compiler can't convert algebraic function text to a C/C++ function pointer.
Beyond that I have NO idea what you are trying to do
|
|
|
|
|
Hi Jessica,
seems to me you want to integrate a differential equation by Runge-Kutta method.
Your class ode expects (constructor):
(1) The starting time t0 .
(2) The initial value of the x variable x0 (x(t0) ).
(3) The ending time T .
(4) The functional description of the equation, strictly speaking, a pointer
to f(x,t) , where x'(t)=f(x,t) .
Now, while it is easy read from a text file three double values, reading the function definition it's not that easy. I suggest you to hard-code the function.
e.g.
double f(double x,double t)
{
return 1. + x*x+t*t*t;
}
int main()
{
int n=1000;
ode part2(0., -4., 1., f);
double* soln2 = part2.rungekuttaforward (n);
return 0;
}
By the way, your code, has many troubles, I think.
Why do you put function definitions in cpp headers?
Why don't you protect your headers for multiple inclusions?
And so on.
|
|
|
|