|
In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
struct tagSIZE butSize,bmpSize;
bmpSize.cx = 25;bmpSize.cy = 23;butSize.cx = 35;butSize.cy = 30;
if(iWindowNumber == 4)
{
if (!m_wndWindowTool.Create(this,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|WS_VISIBLE | CBRS_FLOAT_MULTI) ||
!m_wndWindowTool.LoadBitmap(IDB_GROUPVW) ||
!m_wndWindowTool.SetButtons(CtrlGrp,
sizeof(CtrlGrp)/sizeof(UINT)))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
m_wndWindowTool.SetWindowText("Trend");
m_wndWindowTool.SetSizes( butSize,bmpSize );
m_wndWindowTool.SetHeight( 40 );
CRect rect;
m_wndWindowTool.GetItemRect(0, &rect);
m_wndWindowTool.m_Static.IsTitle = true;
if (!m_wndWindowTool.m_Static.Create("Title",WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,rect, &m_wndWindowTool, IDD_TITLESTATIC) )
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
}
}
Anu
|
|
|
|
|
Anu_Bala wrote: In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.
Did you read the article?
Did you download the code to test/debug it to know how it works?
|
|
|
|
|
I saw that one show CFrameWnd. My window is CMDIChildWnd. So i didnt try first. I tried now. i create CSPlitFrame as CFrameWnd and i coded like below. But when i want my particular window , it shows error on calling that view in Mainframe.cpp.
BEGIN_MESSAGE_MAP(CSplitFrame, CFrameWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()
BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT , CCreateContext* pContext)
{
CTrendListView *pview;
CCreateContext context;
pContext = &context;
pContext->m_pNewViewClass = RUNTIME_CLASS(CTrendListView);
pview = (CTrendListView *) CreateView(pContext, AFX_IDW_PANE_FIRST);
if (pview == NULL)
return FALSE;
SetActiveView(pview, FALSE);
return TRUE;
}
int CSplitFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndWindowTool.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndWindowTool.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; }
m_wndWindowTool.EnableDocking(CBRS_ALIGN_ANY);
m_wndWindowTool.SetBorders(3, 3, 3, 3);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndWindowTool);
return 0;
}
CChildFrame.cpp OnCreateClient()
if (!m_wndSplitter.CreateStatic(this, 2, 1))
return FALSE;
if(!m_wndSplitter.CreateView(0,0, RUNTIME_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||
!m_wndSplitter.CreateView(1,0, RUNTIME_CLASS(CSplitFrame),CSize(cr.Width(), cr.Height()-550),pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
But it shows error in calling TrendView()
if( pTrendDisplayFrame == NULL )
{
iWindowNumber = 4;
CDocTemplate *pTemplate = theApp.pTrendViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL ); if( pTrendDisplayFrame == NULL )
{
MessageBox( "Unable to Create Trend Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
}
else
MDIActivate( pTrendDisplayFrame );
When i create SplitFrame as MDICHildWnd, it shows assertion error. If my main view (TrendView is MDICHildWnd) and TrendListVIew also MDICHildWnd.
Anu
|
|
|
|
|
Anu_Bala wrote: When i create SplitFrame as MDICHildWnd, it shows assertion error.
Where exactly the Assertion fails?
|
|
|
|
|
If i use
class CSplitFrame : public CframeWnd
Here, I call the TrendView using following fucntion in mainfrm.cpp,
void CMainFrame::OnTrendview()
{
if( pTrendDisplayFrame == NULL )
{
iWindowNumber = 4;
CDocTemplate *pTemplate = theApp.pTrendViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pTrendDisplayFrame == NULL )
{
MessageBox( "Unable to Create Trend Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
}
else
MDIActivate( pTrendDisplayFrame );
}
Here it comes messagebox “Unable to create trend display” becoz pTrendDisplayFrmae is null. Frame is not created in CreateNewFrame(),it return null from this function call from doctempl.cpp
if (!pFrame->LoadFrame(m_nIDResource,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context))
{
TRACE(traceAppMsg, 0, "Warning: CDocTemplate couldn't create a frame.\n");
return NULL;
}
When I use CsplitFrame as MDIChilWNd
class CSplitFrame : public CMDIChildWnd
IT shows assertion error in winmdi.cpp
CMDIFrameWnd* CMDIChildWnd::GetMDIFrame()
{
ASSERT_KINDOF(CMDIChildWnd, this);
ASSERT(m_hWnd != NULL);
HWND hWndMDIClient = ::GetParent(m_hWnd);
ASSERT(hWndMDIClient != NULL);
CMDIFrameWnd* pMDIFrame;
pMDIFrame = (CMDIFrameWnd*)CWnd::FromHandle(::GetParent(hWndMDIClient));
ASSERT(pMDIFrame != NULL);
ASSERT_KINDOF(CMDIFrameWnd, pMDIFrame); ASSERT(pMDIFrame->m_hWndMDIClient == hWndMDIClient);
ASSERT_VALID(pMDIFrame);
return pMDIFrame;
}
My TrendView base class is
class CTrendView : public CView
TrendListView base class is also CView
class CTrendListView : public CView
Im invoking this TrendListView as follow
void CMainFrame::OnTrendListView()
{
iGraphView = 0; if( pTrendListDisplayFrame == NULL )
{
iWindowNumber = 11;
CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pTrendListDisplayFrame == NULL )
{
AfxMessageBox( "Unable to Create Tuning Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendListDisplayFrame ,NULL );
}
else
MDIActivate( pTrendListDisplayFrame );
}
When i press Trendpage in main menu, this trend view and trendlistview will display in a same page as splitted window. The window will look like
--------------
Main menu
--------------
Toolbar
-------------
TrendView
--------------
another toolbar
---------------
TrendListview
Anu
modified 17-Jan-19 0:09am.
|
|
|
|
|
Anu_Bala wrote: Im invoking this TrendListView as follow
void CMainFrame::OnTrendListView()
{
iGraphView = 0; if( pTrendListDisplayFrame == NULL )
{
iWindowNumber = 11;
CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
CCS3OprDoc* pDoc = new CCS3OprDoc;
pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
if( pTrendListDisplayFrame == NULL )
{
AfxMessageBox( "Unable to Create Tuning Display" );
return;
}
pTemplate->InitialUpdateFrame( pTrendListDisplayFrame ,NULL );
}
else
MDIActivate( pTrendListDisplayFrame );
}
What is the theApp.pTrendListViewTemplate?
How is it defined/initialized?
|
|
|
|
|
Are there programmers that are currently using machine code and Assembly?
If yes, why?
If yes, are there many programmers that are currently using machine code and Assembly?
If yes, why?
|
|
|
|
|
I'll take a guess!
Quote: Are there programmers that are currently using machine code and Assembly?
YES.
Quote: If yes, why?
Maybe you want to work in computer security?
Quote: So You Want To Be A Malware Analyst - Malwarebytes Labs | Malwarebytes Labs[^]
In order for a Malware Analyst to be able to read the malware code, they will need to disassemble it. Unfortunately, the highest language derived from binary code is Assembly, which is the last level of human readable code. Therefore, it is imperative that a would-be Malware Analyst, also learn how to read and write Assembly code.
Maybe you want your code to be very efficient (very large program, or very minimal computing resources?).
http://www.agner.org/optimize/optimizing_assembly.pdf
See the 10 or so reasons found here:
Quote: 1.1 Reasons for using assembly code
Assembly coding is not used as much today as previously. However, there are still reasons
for learning and using assembly code. The main reasons are:
Or maybe you are working in an embedded environment...
[Digital Logic design, Assembly Language & Embedded Systems development]
Quote:
If yes, are there many programmers that are currently using machine code and Assembly?
If yes, why?
To each his own?
|
|
|
|
|
Almost forgot one entire category: Reverse Engineering.
|
|
|
|
|
@Member 14088880,
Thanks for the your response!
|
|
|
|
|
Never entirely but for sections yes.
It is extremely common on hardware interface code, context switching and sensitive task and API areas because there are very exacting requirements that can not be described by a language even as low as C, much less by a high level language.
In vino veritas
|
|
|
|
|
I use assembly with Microchip 's PIC microcontrollers: most of the code is written in C or C++ , but some routines are coded using assembly.
|
|
|
|
|
The last time I uses anything that low level was to optimize some functions for SSE. Several years before that it was to modify the boot loader in an embedded system.
In the late 1980s and early 1990s, I spent the first three years of my career writing the main product code in assembly (6502 and then 8086) with C for the utilities. The benefits in size and speed were enormous. By the late 1990s, that benefit had shrunk. Even in the embedded space, costs of assembly (mostly time) usually outweigh the benefits.
|
|
|
|
|
|
I hope I can explain this problem.
I can make an instance of a class in my main()
CLASS_I2CIO i2c_ads1115(DEVICE_I2C,ADDRESS_ADS);
no problema.
But if I add same code as class variable - I need an access to the class form main() - I get the following error.
class C_VNA {
public:
C_VNA();
virtual ~C_VNA();
C_Utility utility;
CLASS_LCM1602 i2c; CIOCTLGPIO gpio; C_IOCTL_SPI spi; C_DDS_60 dds; C_AD8302_Detector det;
C_ADS1115 ads;
CLASS_I2CIO i2c_ioctl;
error here
CLASS_I2CIO i2c_ads1115_test(DEVICE_I2C,ADDRESS_ADS);
error here
};
Partial compiler output
Compiler executable checksum: 606522cdd68a1ba2fd9e2930e9d38d0d
In file included from ../src/MODULES/M_VNA/CVNA.cpp:8:0:
../src/MODULES/M_VNA/CVNA.h:28:20: error: expected identifier before string constant
#define DEVICE_I2C "dev/i2c-1"
^
../src/MODULES/M_VNA/CVNA.h:60:36: note: in expansion of macro ‘DEVICE_I2C’
src/MODULES/M_VNA/subdir.mk:18: recipe for target 'src/MODULES/M_VNA/CVNA.o' failed
CLASS_I2CIO i2c_ads1115_test(DEVICE_I2C,ADDRESS_ADS);
^
../src/MODULES/M_VNA/CVNA.h:28:20: error: expected ‘,’ or ‘...’ before string constant
#define DEVICE_I2C "dev/i2c-1"
^
../src/MODULES/M_VNA/CVNA.h:60:36: note: in expansion of macro ‘DEVICE_I2C’
CLASS_I2CIO i2c_ads1115_test(DEVICE_I2C,ADDRESS_ADS);
^
make: *** [src/MODULES/M_VNA/CVNA.o] Error 1
There is nothing special about #defines
#define DEVICE_SPI "dev/spidev0.0"
#define DEVICE_I2C "dev/i2c-1"
#define ADDRESS_HITACHI 0x27
#define ADDRESS_ADS 0x48
The error "points " to #define which is redefined in this class - temporary for test purposes.
I did look thru similar problems and they all indicate the #define is NOT the issue, however I am unable to figure this out and correct it.
Any help would be appreciated.
Cheers
|
|
|
|
|
Where is the definition of CLASS_I2CIO and its constructors?
|
|
|
|
|
Here is the part in question
class CLASS_I2CIO {
public:
CLASS_I2CIO();
CLASS_I2CIO(char Device, int Address);
CLASS_I2CIO(int width, int length, int height)
: m_width(width), m_length(length), m_height(height)
{}
CLASS_I2CIO(char *x1, int y1);
this is the one which fails
CLASS_I2CIO(char *x1, int y1, int Width, int Height);
private:
char *device;
int address;
int width, height;
public:
virtual ~CLASS_I2CIO();
int FileDescriptor = 0;
__u8 reg;
__s32 res;
char buffer[10]= { };
|
|
|
|
|
That is incomplete, and will not even compile, so it is impossible to guess what else may be wrong.
[edit]
See Graham's answer below.
[/edit]
modified 14-Jan-19 5:52am.
|
|
|
|
|
CLASS_I2CIO(char Device, int Address);
Surely you mean char* Device , not char Device ?
If the erroneous line is supposed to be an initialization of a variable calling this constructor, then that is not going to work: you can not initialize a member variable right inside the class declaration, unless it is static. Instead you have to do the initialization inside the constructor, like this:
class C_VNA {
C_VNA();
...
CLASS_I2CIO i2c_ads1115_test; };
...
C_VNA::C_VNA()
: i2c_ads1115_test(DEVICE_I2C,ADDRESS_ADS)
{
}
[edit2]reintroduced tags [/edit]
modified 17-Jan-19 7:28am.
|
|
|
|
|
Stefan_Lang wrote: had to remove tags - for some reason they are not working!? Look at the checkboxes below the edit window. Do you have "Treat my content as plain text, not as HTML" set?
|
|
|
|
|
Thanks, that was indeed the problem. No idea why it was checked - I almost always use tags.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Vaclav_ wrote: The error "points " to #define which is redefined in this class - temporary for test purposes. Are you doing something like this?
#include "spi.h" // #defines DEVICE_SPI, etc
#define DEVICE_SPI_"dev/spidev0.0" // Temporary define
class C_VNA {
};
That would mean that you're re-defining DEVICE_SPI, but normally your compiler should warn about redifines. Maybe you need #undef where you set up your temp defines. e.g.
#ifdef DEVICE_SPI
#define ORIG_DEVICE_SPI DEVICE_SPI
#undef DEVICE_SPI
#endif
#define DEVICE_SPI "dev/spidev0.0"
#ifdef ORIG_DEVICE_SPI
#undef DEVICE_SPI
#define DEVICE_SPI ORIG_DEVICE_SPI
#undef ORIG_DEVICE_SPI
#endif
|
|
|
|
|
Inside a function, this declares a variable called i2c_ads1115 with type CLASS_I2CIO and calls the constructor with the two values DEVICE_I2C and ADDRESS_ADS :
CLASS_I2CIO i2c_ads1115(DEVICE_I2C,ADDRESS_ADS);
Inside a class definition it declares a member function called i2c_ads1115 that returns a CLASS_I2CIO type and takes two arguments, which is where the compiler is having problems. Instead of DEVICE_I2C being a type, you have a #defined string.
To get i2c_ads1115 as a member variable, declare it the same way as the i2c_ioctl member variable, then construct it with arguments in the initialization list of the C_VNA class.
|
|
|
|
|
Thanks, I'll give it a go.
One more question.
Why I have no issue with using same syntax making an instance of the class in main ()?
Stupid question - could I just change the #define to "include" type ?
|
|
|
|
|
I can't say why that syntax defines a variable using a constructor in one place and declares a member function in another - you would have to ask the people who designed C++ that.
Making the #define include the type would probably give you a different error message, but it would still be attempting to declare a member function.
|
|
|
|
|