Visual C++ :: How To Get Pointer To CDialogBar From CView Class
Nov 22, 2013
My program (Test) is a basic MFC AppWizard (exe) created project. I have followed the steps in the link below to create a docked dialog box (myDialog) using VC++. [URL]...
The dialog box works, however, I have 2 issues that I am trying to resolve.
1) I have added a button to the Dialog box, however, when I run the application they start as disabled (note: the Disabled option on the Button Properties is unchecked). If I add function myDialog::OnButton to the myDialog class, the button remains disabled, however, if I add the function CTestView::OnButton to the View class, the button becomes active and works. How can I make the button work from the myDialog class?
2) I would like to be able to change an Edit box in the same dialog box when I click the button. How can I access the pointer to the myDialog from the View class?
View 2 Replies
ADVERTISEMENT
Feb 17, 2014
Special behaviour of a CEdit-control in a CDialogBar:
My CDialogBar is a member of my MDI-mainframe-class. The menu of the mainframe have an item with an accelerator "r".
Now, if I want to type the letter "r" in my CEdit-control, the menu-item (with the accelerator "r") will be called.
How can I type "r" into the CEdit-control? How can I handle it?
View 2 Replies
View Related
Feb 11, 2014
I have the following problem:
My mainframe-window in a MDI-app has a CDialogbar.
Every time the mouse moves over a control in this dialogbar the status bar is updated by a text.
The app craps the text from the resource strings that has the same ID than the dialogbar-control, randomly.
I do not want this. How can I avoid this?
View 14 Replies
View Related
Dec 16, 2013
I'm trying to create an edit box in a CView.So far, this is how far I've gotten:
With this code
Code:
// .h
CEdit m_MyEditField;
// .c
m_MyEditField.Create(WS_CHILD | WS_VISIBLE,CRect(40,40,500,Y+55),this,0x1552);
m_MyEditField.SetWindowText("this is my CEdit field");
As you can see, the edit box doesn't look like the ones in a dialog, which is what I'm trying to accomplish.
Is there possibly some other class I should be using for the edit box?Or another setting for .Create?
View 2 Replies
View Related
Jul 11, 2014
I have an problem with a CDialogbar if my app runs on a system with two screens (side by side). I can not resize it while the CDialogbar is in floating state on the second screen.
I figured out that the problem is the mfc-function CDockContext::Stretch().
It limits the CDialogbar to the primary screen (using ::GetDesktopWindow() to verify the position).
What can I do?
View 2 Replies
View Related
Feb 10, 2013
I have an SDI / CView app (VS 2010). All works well until I minimize the app using the minimize button or drag it partially off of the screen. In the former instance, any attempt to restore the app results in an appcrash with a tight freeze up of the machine. In the later instance the same happens immediately.
In building the app, I scoured the web for code to accomplish the loading and display of the bitmap. After some experimentation I settled on overriding the OnPaint. Below is the code. Note that m_Map is a CBitmap member and IDB_BITMAP1 is a loaded bitmap resource.
Code:
void CMyDragViewView::OnPaint()
{
// CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
// http://msgroups.net/microsoft.public.vc.mfc/loading-bitmaps-into-main-window/563285
int x = m_Map.LoadBitmap(IDB_BITMAP1);
TRACE1(" x = %d
", x);
CPaintDC* dc = new CPaintDC(this);
[code]....
I suspect that the problem is OnPaint trying to repaint the bitmap which requires reloading it, but I don't know how to work around this.
View 3 Replies
View Related
Dec 12, 2012
I am attaching a sample project. Basically what this project does is that I initialize a variable map<CString, bool*> m_mapTest in CView::OnInitialUpdate and then pass the variable to CDocument class. On the other hand, within the function OnSaveDocument defined in CDocument I check m_mapTest. To my surprise, the CString part of m_mapTest is correct but the bool* part of m_mapTest is wrong(I pass an array of bool in CView::OnInitialUpdate).
View 3 Replies
View Related
Feb 25, 2014
I'm using the Feature Pack CTabView, and I noticed that when the view is added using AddView with the following code CView's HWND is NULL when I try and access each of the CView1,CView2, etc.
Code:
int CMyTabView::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CTabView::OnCreate(lpCreateStruct) == -1)
return -1;
AddView (RUNTIME_CLASS (CView1), _T("Simple"),100);
AddView (RUNTIME_CLASS (CView2), _T("Pair"),101);
AddView (RUNTIME_CLASS (CView3), _T("Data"),102);
return 0;
}
I think the user has to click the view's tab before the CTabView assigns an HWND. Is there a way to force CTabview to give each CView an HWND when the view is added?
View 11 Replies
View Related
Sep 14, 2013
I have been working with both Chris Mander's MFC grid and the Ultimate Grid.
See for details:
The Ultimate Grid Beginner's Guide By The Ultimate Toolbox, 25 Aug 2007 : [URL] ....
MFC Grid control 2.27 By Chris Maunder, 6 May 2010 : [URL] ....
Both of these grid controls work nicely in a SDI CView windows. But when I create a split window using CSplitterWnd and the following code in an attempt to create a split window with a CListView and and a CView using this code:
Code:
// in CMainFrame.h
// Attributes
public:
CSplitterWnd m_wndSplitter;
//..
// in CMainFrame.cpp
//..
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
[Code] .....
The grid in the CView window appears but is frozen in both instances. I suspect there is some notification necessary to for the grid to send and receive messages from the split CView window, but I cannot figure out how to implement this notification.
Unfortunately, even a demo application would be too large to append, but for anyone that is interested, the split method is encapsulated in the code I've presented here and the implementation of both grid controls is well explained in the links provided.
View 6 Replies
View Related
Feb 19, 2013
I have a question concerning the CDialogBar (:CControlBar).
I have a MDI application with a dockable toolbox (CDialogBar).
The user is able/allowed to move the DialogBar and to dock it at the right or left side When I dock at the left side, the content of my mdi-application (so all other open windows) are moved right (so the dockable bar moves the windows).
If i dock at the right side, nothing changes.
How can I change the behaviour of the bar, that the windows inside the application keep the same position when I dock left ?
(Problem is, that my windows are aligned on the right side of the application). When I dock the bar on the left, the windows are getting moved in the not visible area.)
View 2 Replies
View Related
Nov 29, 2013
My program is a basic MFC AppWizard (exe) created project in VC++ 6. In MainFrm.cpp, I am trying to access some user defined CMyView member functions. However when I try to do the standard procedure to get the CMyView pointer in MainFrm.cpp, I get the " ... 'CMyView' : undeclared identifier" error. To resolve this, I add " #include myView.h " at the top of MainFrm.h which then produces the following errors:
Code:
myview.h(21) : error C2143: syntax error : missing ';' before '*'
myview.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
myview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
What do these errors mean? Is there a simple way to access CMyView member functions from CMainFrame?
View 8 Replies
View Related
Oct 3, 2012
I have encountered a problem I can't see to solve. I want to access a function and can't seem to find the right combination to get me there. Here is what I am looking at:
CFoo1::CFoo2::GetStrDataC(int nRow) const
How do I call the GetStrDataC function from another class?
View 6 Replies
View Related
Oct 14, 2013
I have a function called,
App 1:
void GetImage(CImage * img) {
//Pass &img over socket to another app
}
App 2:
void DisplayImage() {
CImage * pImg = &img;
}
Is it possible to pass a class pointer as memory buffer across the socket? The above code is just an example. My question in general is, whether it's possible to pass any Classes pointer as a memory buffer across sockets.
View 7 Replies
View Related
Mar 9, 2013
I need understanding this block of code, particularly this line : *getLeftChild() { return this - _child; }
Code:
public class UpperNode {
BOX _box;
int _child;
FORCEINLINE UpperNode *getLeftChild() { return this - _child; }
...
};
Here I have this function:
Code:
void
UpperNode::visulization(int level) {
if (isLeaf())
_box.visulization();
else
if ((level > 0)) {
[Code] .....
It also makes calls for "getLeftChild()";
But I see that getLeftChild expects function pointer, and I absolutely have no clue where "this" comes from inside function body.
(return this - _child) - "this" has to be integer.
Or, if we gave pointer, and "this" is referring to some UpperNode, then I can't understand to which one, I have no UpperNode array defined or something. So if this functions is actually scaling pointer address, then scaling where to? I could comprehend it, if I had some array of UpperNodes, but not just class. I have UpperNodes array defined in other friendly class, but don't think they are related .....
View 2 Replies
View Related
Jun 16, 2013
Here is the pseudocode,
Code:
class myDX9Widget {
std::vector<Object*> m_vRenderObjects;
};
class Object {
};
class Lorry : public Object {
Activity *activity;
[Code] .....
Don't worry about the exact syntax here, I'd like to concentrate, on a conceptual level, why the line
lorry->Owner->m_vRenderObjects.push_back(pallet);
is not allowed
lorry is regarded as "Pointer to incomplete class"
View 4 Replies
View Related
Feb 6, 2015
I create an instance of a base class (not derived class) and assign it to base class pointer. Then, I convert it to a pointer to a derived class and call methods on it.
why does it work, if there is a virtual table?
when will it fail?
// TestCastWin.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
#include <iostream>
class B
{
public:
B(double x, double y) : x_(x), y_(y) {}
double x() const { return x_; }
[Code] ....
View 14 Replies
View Related
Aug 19, 2014
I am attempting to implement function pointers and I am having a bit of a problem.
See the code example below; what I want to be able to do is call a function pointer from another pointer.
I'll admit that I may not be explaining this 100% correct but I am trying to implement the code inside the main function below.
class MainObject;
class SecondaryObject;
class SecondaryObject {
public:
[Code]....
View 10 Replies
View Related
Mar 21, 2015
In this book, item 3 is about never treat arrays polymorphically. In the latter part of this item, the author talks about the result of deleting an array of derived class objects through a base class pointer is undefined. What does it mean? I have an example here,
Code:
class B
{
public:
B():_y(1){}
virtual ~B() {
cout<<"~B()"<<endl;
[Code] ....
This sample code does exactly what I want. So does the author mean the way I did is undefined?
View 1 Replies
View Related
Jun 28, 2012
I'm trying to implement a class hierarchy and a wrapper class with a pointer to the base class. The base class has operator< overloaded and the implementation makes use of virtual functions as some of the logic for sorting is in the derived classes. Unfortunately, when trying to use the base class operator< from the wrapper, I get a "pure virtual method called".
Below code is meant to illustrate my problem. Unfortunately it crashes on me (upon destruction of vec) and I cannot quite see, why. So two questions:
1. spot the error I made in the code below (having lived in Java-land for the last 5 years, I'm sure I just did some stupid error)?
2. How can I implement Wrapper::operator< to use Base::operator<? I know I could write a function and pass it to sort but I'm interessted if there is a way to actually use Base::operator<.
Code:
#include <vector>
#include <algorithm>
#include <cmath>
[Code].....
View 3 Replies
View Related
Aug 2, 2013
I'm currently reading the C++ Guide for Dummies
Anyway right now I'm working with pointers and classes, and when I create a new pointer for my class it looks like this...
Pen *Pointerpen = new Pen;
But in the book they threw in this...
Pen *Pointerpen = new Pen();
Can you actually designate memory space for a function? Or was this a typo on their part? It's never come up before and they didn't explain it.
View 5 Replies
View Related
May 18, 2013
A pointer to base class, if assigned to a derived class, only points to the base part right? So you can only use the base part of the derived class with that pointer and no methods from the derived class?
View 8 Replies
View Related
Feb 4, 2014
I came across a piece of c++ code that seems to be initializing a class object like this:
ImapMailbox *mailbox;
Now the class looks like this:
class ImapMailbox {
public:
ImapMailbox();
ImapMailbox (const QString& mailbox);
~ImapMailbox();
// Methods
void addMessage (ImapMessage *message);
[Code]...
And the constructor looks like this:
ImapMailbox::ImapMailbox()
: d(new ImapMailboxPrivate)
{
d->unseen = d->exists = d->recent = 0;
d->readWrite = false;
d->flags = 0;
}
But this does not seem to be an array like object. So what exactly could this be pointing to?
View 2 Replies
View Related
Dec 10, 2012
Linker error.
First off the error
Code:
Error1error LNK2019: unresolved external symbol "public: __thiscall ReachTop<class Character>::ReachTop<class Character>(class Character *)" (??0?$ReachTop@VCharacter@@@@QAE@PAVCharacter@@@Z) referenced in function "void __cdecl `dynamic initializer for 'gReachTop''(void)" (??__EgReachTop@@YAXXZ)Main.objDecisionTest
Reach Top class inherits from Goal Class
Goal Class
Code:
#ifndef _GOAL_H
#define _GOAL_H
#include "Action.h"
#include <list>
template <class T>
class Goal
[Code] ....
Code to create
Code:
Character* gCharacter = new Character(1, gWorld);
Goal<Character>* gReachTop = new ReachTop<Character>(gCharacter);
I can provide the character class and its inheritance aswell if you like.
View 4 Replies
View Related
Aug 29, 2014
I have a query regarding virtual destructor functionality. So below is sample code:
Code:
#include<iostream>
#include<stdlib.h>
using namespace std;
class Base
Code: Base *b = d;
Here b and d now pointing to same memory location.
Now below statement:
Code: delete (b);
Here since my destructor is virtual it will call derived class and base class destructor.
Now my question is, if I use this:
Code: delete (d); // And without virtual keyword in ~Base() {} This call both derived and base class destructor.
So which one is correct form to call and why? Is delete(b) is standard in virtual function mechanism.
Output is:
D1 :: function1()
Base :: function2()
INSIDE D1 DES
INSIDE BASE DES
View 2 Replies
View Related
Jan 10, 2015
I have the following scenario :
Code:
class test {
public :
int num;
};
int main() {
test t1;
test *ptr = &t1;
int test :: *mem_ptr = &test::num;
}
I need to access mem_ptr (pointer to a class member) through :
a. object (t1)
b. pointer to the object (ptr).
How can i do that ?
View 4 Replies
View Related
Oct 10, 2013
If I need a static pointer to a class that is used globally(multiple files), and I only want to allocate memory once.
One way is to create a function that returns a static pointer of type class and call it where ever you need this pointer. My question is there another way to do this like with a header file and include the header file where you need to use the object of type class.
static class* function
{
static class c;
if (c == NULL)
{
c = new class;
}
return c
}
View 1 Replies
View Related