|
pre>
<br />
<br />
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)<br />
{<br />
m_wndSplitter.CreateStatic(this, 1, 2);<br />
<br />
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftPanel), CSize(400, 400), pContext);<br />
m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightPanel), CSize(400, 400), pContext);<br />
m_wndSplitter.SetActivePane(0, 0);<br />
<br />
return TRUE;<br />
}<br />
#pragma once
class CLeftPanel : public CDialog
{
DECLARE_DYNCREATE(CLeftPanel)
public:
CLeftPanel(CWnd* pParent = NULL);
virtual ~CLeftPanel();
enum { IDD = IDD_FORMVIEW_LEFT };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
};
#include "stdafx.h"
#include "SplitForm.h"
#include "LeftPanel.h"
IMPLEMENT_DYNCREATE(CLeftPanel, CDialog)
CLeftPanel::CLeftPanel(CWnd* pParent )
: CDialog(CLeftPanel::IDD, pParent)
{
}
CLeftPanel::~CLeftPanel()
{
}
void CLeftPanel::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CLeftPanel, CDialog)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()
BOOL CLeftPanel::OnEraseBkgnd(CDC* pDC)
{
return CDialog::OnEraseBkgnd(pDC);
}
void CLeftPanel::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDblClk(nFlags, point);
this->MessageBox((LPCTSTR)_T("Test"), NULL);
}
Both the LeftPanel and RightPanel and blank. Why the controls on LeftPanel and Right Panel donot display?
|
|
|
|
|
You could try to use a CFormView derivation for your panes...
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
yu-jian wrote: Why the controls on LeftPanel and Right Panel donot display?
What controls? I see nothing in CLeftPanel that indicates it has any controls.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I had drawed two buttons to the Dialog IDD_FORMVIEW_LEFT
in the Form design tools.
|
|
|
|
|
yu-jian wrote: I had drawed two buttons to the Dialog IDD_FORMVIEW_LEFT...
But there are no control variables in CLeftPanel . There's also nothing shown in DoDataExchange() . Why?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes, I not band the variable to button control. I only draw this button to the FormView. So it does not show?
|
|
|
|
|
Hi all,
i m using a Tree Ctrl,i want to identify whether i clicked over hash button or item label.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
You'll probably want to do something like this when handling the NM_DBLCLK notification:
case NM_DBLCLK:
HTREEITEM hItem = (HTREEITEM)SendMessage(((LPNMHDR) lParam)->hwndFrom,TVM_GETNEXTITEM,TVGN_CARET,0);
TVITEM tvi;
tvi.mask = TVIF_PARAM;
tvi.hItem = hItem;
SendMessage(((LPNMHDR) lParam)->hwndFrom,TVM_GETITEM,0,(int)&tvi);
break;
tvi.lParam now contains the lParam value you added to the item when you added it to the tree view. You could use this value to give information on the content, e.g. if it is a hash button or item label.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
i want to write a a program that will accept student name and grades and output it.use an array data structure in the implementation this program and implement the following
write method that will traverses the array and allow the user to perform the following processes
a) search for a particular student and his or her marks
b)find the average of all the student in the class
c)find all student with a mark below 50 and output them.
i started off with this codes in Java .But the thing is if i can do it in java i can do it in C and C++
import java.util.Scanner;
//import java.lang.String;
public class Main {
public static int n;
//public static String names;
//private static String[] nameS;
//private static String[] nameS;
/**
* @param args the command line arguments
*/
public static void main(String[] args/*,String[] nameS*/) {
Scanner in=new Scanner(System.in);
int Da=0;
int num []=new int[n];
//int x=0;
System.out.printf("%s\n","Enter the Number of student taking This Couse");
n=in.nextInt();
String name[]=new String [n];
System.out.printf("%s %s \n", "index","value");
for (; Da < name.length; Da++ )/*Da 4 Display array*/ {
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
System.out.println("Enter the names of the student");
String names;
names=in.nextLine();
name[n] = new String(names);
for (; Da < name.length; Da++ ){
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
}
}
i can not input the names into the array( name) i created
pls help me
|
|
|
|
|
Please don't cross post this in multiple forums. Make up your mind whether you want an answer to C/C++ or Java.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
and please use PRE tags for code snippets, I'm not going to read that unformatted unindented stuff!
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Saturday, December 4, 2010 12:01 AM
|
|
|
|
|
Hi,
In this area there are some differences between C++ and Java.
To input nb values of type Val from some stream (console, file or string) to a C++ std::array<Val, nb> you can use:
#include <iostream>
#include <array>
using std::tr1::array;
template <class Val, size_t nb>
array<Val, nb> Input(std::istream& in)
{
array<Val, nb> vals = {0};
while (!in.eof())
{
std::copy_n(std::istream_iterator<Val>(in), vals.size(), vals.begin());
if (in.good())
break;
in.clear();
in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
};
return vals;
}
int main()
{
std::cout << "Input five integers" << std::endl;
array<int, 5> vals = Input<int, 5>(std::cin);
std::copy(vals.begin(), vals.end(), std::ostream_iterator<int>(std::cout, "\n"));
return 0;
}
Good luck
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Saturday, December 4, 2010 6:08 AM
|
|
|
|
|
/*
Program: Drink Machine
Programmer: Cachel Caldiero
Date: November 16, 2010
Purpose: Simulate a drink machine
*/
#include <iostream>
#include <string>
using namespace std;
// Function Prototypes
void banner();
void menu();
int getMoney();
bool enough(double);
void getDrink();
void dispenseChange(double);
// Main function
int main ()
{
double money = 0.0;
//display banner
banner();
menu();
//While not enough money
while (!enough(money))
{
//Add money based upon option selected
switch (getMoney())
{
case 1: cout << "You have entered $1.00" << endl;
break;
case 2: cout << "You have entered 25 cents" << endl;
break;
case 3: cout << "You have entered 10 cents" << endl;
break;
case 4: cout << "You have entered 5 cents" << endl;
break;
}
//Tell user how much money has been deposited already
cout << endl << "Current amount deposited is " << money << endl;
}
//determine drink selection
getDrink();
//dispense change
if (money > 1.00)
dispenseChange(money);
return 0;
}
// Function Definitions
void banner()
{
cout << "MMM DDD" << endl
<< "OOO EEE" << endl
<< "UUU WWW" << endl
<< "NNN " << endl
<< "TTT " << endl
<< "AAA " << endl
<< "III " << endl
<< "NNN " << endl;
}
void menu()
{
cout << "Pick your drink" << endl
<< "1. Pepsi" << endl
<< "2. Diet Pepsi" << endl
<< "3. Mountain Dew" << endl
<< "4. Diet Mountain Dew" << endl
<< "5. Bottled Water" << endl;
}
int getMoney()
{
int opt;
cout << "Please deposit $0.25." << endl;
cout << "1.Dollar" << endl
<< "2.Quarter" << endl
<< "3.Dime" << endl
<< "4.Nickel" << endl;
cin >> opt;
return opt;
}
bool enough(double m)
{
bool opt(double);
//is there enough money?
if (opt >= enough)
cout << "Enough money inserted" << endl;
else
cout << "Need more money" << endl;
}
void getDrink()
{
string drinkSelection = "";
int option;
//display selection menu
cout << "Pick your drink" << endl;
cout << "1.Pepsi" << endl
<< "2.Diet Pepsi" << endl
<< "3.Mountain Dew" << endl
<< "4.Diet Mountain Dew" << endl
<< "5.Bottled Water" << endl;
//read input selection for drink
cin >> option;
//determine what drink is selected
getDrink();
//output here is your drink.. message
cout << "Here is your drink" << endl;
}
void dispenseChange(double m)
{
int getMoney();
//determine the change in coins.. for example 2 dimes, 1 nickel.
if (getMoney == 1)
cout << "Your change is $0.75 or 3 quarters.";
if (getMoney == 2)
cout << "Your change is $0.50 or 2 quarters.";
else if (getMoney == 3)
cout << "Your change is $0.25 or 1 quarter.";
}
|
|
|
|
|
What exactly is happening that's not right? Also, please format your code with <pre> tags to make it reasonably readable.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
What are
tags?
My main problem is part of code that follows:
void dispenseChange(double m)
{
int getMoney();
if (getMoney = 1)
cout << "Your change is $0.75 or 3 quarters.";
if (getMoney = 2)
cout << "Your change is $0.50 or 2 quarters.";
else if (getMoney == 3)
cout << "Your change is $0.25 or 1 quarter.";
}
|
|
|
|
|
It's hard to read in this format, but I think there is more wrong than just this function.
Your dispenseChange functions accepts a double m, which contains the amount of money inserted. The function is called when the amount is more than 1.00. The price of a drink is 25ct, so why not call this function when the amount is more than 0.25?
Then when you're in the function dispenseChange, you call GetMoney. So after you have inserted too much money already and change is calculated, you ask for another coin to be inserted and then base the change on that coin.
The change should be based on the amount paid and the price: so m-0.25 is the amount that is paid too much. Then you'd have to split this to coins.
Other observations:
In your main loop, you check until you have inserted enough money. You do this by calling getMoney(), but you don't update your money variable. So the enough(money) check won't be right either.
Your getDrink function calls itself.
Maybe try something like this:
using namespace std;
void banner();
void menu();
int getMoney();
bool enough(double);
void getDrink();
void dispenseChange(double);
int main ()
{
double money = 0.0;
banner();
menu();
while (!enough(money))
{
switch (getMoney())
{
case 1: cout << "You have entered $1.00" << endl;
money += 1.00;
break;
case 2: cout << "You have entered 25 cents" << endl;
money += 0.25;
break;
case 3: cout << "You have entered 10 cents" << endl;
money += 0.10;
break;
case 4: cout << "You have entered 5 cents" << endl;
money += 0.05;
break;
}
cout << endl << "Current amount deposited is " << money << endl;
}
getDrink();
if (money > 0.25)
dispenseChange(money);
return 0;
}
void banner()
{
cout << "MMM DDD" << endl
<< "OOO EEE" << endl
<< "UUU WWW" << endl
<< "NNN " << endl
<< "TTT " << endl
<< "AAA " << endl
<< "III " << endl
<< "NNN " << endl;
}
void menu()
{
cout << "Pick your drink" << endl
<< "1. Pepsi" << endl
<< "2. Diet Pepsi" << endl
<< "3. Mountain Dew" << endl
<< "4. Diet Mountain Dew" << endl
<< "5. Bottled Water" << endl;
}
int getMoney()
{
int opt;
cout << "Please deposit $0.25." << endl;
cout << "1.Dollar" << endl
<< "2.Quarter" << endl
<< "3.Dime" << endl
<< "4.Nickel" << endl;
cin >> opt;
return opt;
}
bool enough(double m)
{
if (m >= 0.25){
cout << "Enough money inserted" << endl;
return 1;
}
else{
cout << "Need more money" << endl;
return 0;
}
}
void getDrink()
{
int option;
cout << "Pick your drink" << endl;
cout << "1.Pepsi" << endl
<< "2.Diet Pepsi" << endl
<< "3.Mountain Dew" << endl
<< "4.Diet Mountain Dew" << endl
<< "5.Bottled Water" << endl;
cin >> option;
cout << "Here is your drink" << endl;
}
void dispenseChange(double m)
{
if (m == 1.20)
cout << "Your change is $0.95 or 3 quarters and 2 dimes.";
else if (m == 1.15)
cout << "Your change is $0.90 or 3 quarters and a dime and a nickel.";
else if (m == 1.10)
cout << "Your change is $0.85 or 3 quarters and a dime.";
else if (m == 1.05)
cout << "Your change is $0.80 or 3 quarters and a nickel.";
else if (m == 1.00)
cout << "Your change is $0.75 or 3 quarters.";
else if (m == 0.45)
cout << "Your change is $0.20 or 2 dimes.";
else if (m == 0.40)
cout << "Your change is $0.15 or a dime and a nickel.";
else if (m == 0.35)
cout << "Your change is $0.10 or a dime.";
else if (m == 0.30)
cout << "Your change is $0.05 or a nickel.";
}
modified on Saturday, December 4, 2010 6:40 AM
modified 13-Sep-18 21:01pm.
|
|
|
|
|
you get mixed up betwen "=" and "==" ...
review your courses texts and documentations.
Watched code never compiles.
|
|
|
|
|
To open a drive/disk and read data from it there are many ways like CreateFile/ReadFile, _open/_read etc
do we have any code written in assembly language which open disk and read data from it from any location. And we can use that code in vc++. If yes please provide any link
|
|
|
|
|
You are not going to improve performance by writing assembly code to read/write files, because there's a bigger bottleneck at the disk i/o level (the data transfer from/to the disk happens at a MUCH slower pace than the speed at which the program itself executes).
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|
|
ok. What about data reading. Using VC++ function sometime API hangs which read data. Will assembly code success in this. And to read data asynchronously is not reliable because it depends on disk to disk.
|
|
|
|
|
There's no reason why a C++ API should "hang" as such while reading a file. It may be due to disk latency, which cannot be cured if you change the programming language that was used to read data.
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|
|
|
Don't bother trying to use assembly language for this type of thing. Under modern operating systems you're always going to have to use some OS service to access the disk whatever language you're programming in. Even if you write a device driver to do the access there's no point in using an assembly language as writing it in C will be easier and probably as fast and efficient. And even if you write a device driver you're still relying on the OS to call the driver for you so you're still at the mercy of the OS.
Cheers,
Ash
|
|
|
|
|
Thanks
I experienced that asynchronous disk io is not reliable. Am i correct?
If not then please give some idea about the way to use it
|
|
|
|
|
What do you mean with "reliable" ?!?
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|