|
Hi All,
I stuck with a small problem in RichEditControl.My Requirement is i have a dialog box.I need to add a button naming UNDO.i have done some operations(copy,paste,delete) on RichEditCtrl placed on that Dialog,If i pressed that UNDO button the last change should be undone.This is my Requirement.
I Used Like this:
if(richeditobj.CanUndo())
{
richeditobj.Undo())
}
For me CanUndo is not returning Correct return Value.
Thanks in Advance
Aravind
If you have faith in the cause and
the means and in God, the hot
Sun will be cool for you.
|
|
|
|
|
|
I am currently working out a project using Digital Gates, we've done the implementation of the circuit and the results will all ok. But there was a problem that i am facing currently, my Digital Gates will always disappear when i minimize or maximize the screen of my program.
I know that i can use CWnd::UpdateWindow to refresh the screen, but i do not know how and also what are the parameters and arguments should i add in?
Can anyone guide me through this difficult stage thank you.
From: Guilbert
|
|
|
|
|
popo84 wrote:
my Digital Gates will always disappear when i minimize or maximize the screen of my program.
you have two solution to this problem :- either create your window with CS_SAVEBITS Class style which make your drawing on screen persistent! (look for more detail about above property in RegisterClass documentation)
or Handle WM_PAINT message to draw your Image Every Time the Windows Refreshes. also you can manually refresh your window by using CWnd::Invalidate()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
But i did not use WM_PAINT, i created my own Function with parameters
Below is what i created:
void ShowBitmap(int x, int y, int Gate)
{
CDocument* pDoc = GetDocument();
CClientDC dc(this);
CBitmap bitmap;
CDC dcMemory;
BITMAP bm;
switch (kind) {
case AND :
bitmap.LoadMappedBitmap(IDB_AND,0);
break;
case NAND :
bitmap.LoadMappedBitmap(IDB_NAND,0);
break;
case OR :
bitmap.LoadMappedBitmap(IDB_OR,0);
break;
case NOR :
bitmap.LoadMappedBitmap(IDB_NOR,0);
break;
case NOT :
bitmap.LoadMappedBitmap(IDB_NOT,0);
break;
case XOR :
bitmap.LoadMappedBitmap(IDB_XOR,0);
break;
case XNOR :
bitmap.LoadMappedBitmap(IDB_XNOR,0);
break;
case DLR :
bitmap.LoadMappedBitmap(IDB_DLR,0);
break;
case SLR :
bitmap.LoadMappedBitmap(IDB_SLR,0);
break;
case _1TO2LR :
bitmap.LoadMappedBitmap(IDB_1TO2LR,0);
break;
case UD :
bitmap.LoadMappedBitmap(IDB_UD,0);
break;
case UL :
bitmap.LoadMappedBitmap(IDB_UL,0);
break;
case UR :
bitmap.LoadMappedBitmap(IDB_UR,0);
break;
case DL :
bitmap.LoadMappedBitmap(IDB_DL,0);
break;
case DR :
bitmap.LoadMappedBitmap(IDB_DR,0);
break;
case LT_ON:
bitmap.LoadMappedBitmap(IDB_LT_ON);
break;
case LT_OFF:
bitmap.LoadMappedBitmap(IDB_LT_OFF);
break;
case _DEL :
bitmap.LoadMappedBitmap(IDB_EMPTY,0);
break;
case START :
if(kind==START)
m_dStart.DoModal(); //popup dialog box
if (m_dStart.StartValue==0)
bitmap.LoadMappedBitmap(IDB_START0,0);
else
bitmap.LoadMappedBitmap(IDB_START1,0);
//UpdateData(FALSE);
break;
case END :
bitmap.LoadMappedBitmap(IDB_END,0);
break;
default : break;
}
bitmap.GetObject(sizeof(BITMAP),&bm);
dcMemory.CreateCompatibleDC(&dc);
dcMemory.SelectObject(&bitmap);
dc.BitBlt(x,y,bm.bmWidth,bm.bmHeight,&dcMemory,0,0,SRCCOPY);
}
|
|
|
|
|
Now Simple Draw the Bitmap using this piece of code
void <your class>::OnPaint()
{
this->ShowBitmap(x,y,Gate);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi Again thanks for your help
Next Step what should i do?
From: popo84
|
|
|
|
|
Hi again i already follow your instruction and putting
this->ShowBitmap(x,y,Gate);
but got some errors:
c:\Documents and Settings\Administrator\My Documents\My Received Files\Jingpo work\E-learn_ruler_gate_SDObject\E-learn\E-learnView.cpp(1347): error C2144: syntax error : 'int' should be preceded by ')'
c:\Documents and Settings\Administrator\My Documents\My Received Files\Jingpo work\E-learn_ruler_gate_SDObject\E-learn\E-learnView.cpp(1347): error C2660: 'CElearnView::ShowBitmap' : function does not take 0 arguments
c:\Documents and Settings\Administrator\My Documents\My Received Files\Jingpo work\E-learn_ruler_gate_SDObject\E-learn\E-learnView.cpp(1347): error C2059: syntax error : ')'
Thanks for your help really
From: popo84
|
|
|
|
|
popo84 wrote:
Hi again i already follow your instruction and putting
this->ShowBitmap(x,y,Gate);
is ShowBitmap is member of view class
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Yes it is a member of the View Class and just want to tell you that our View Class is being change to ScrollView
From: Guilbert
|
|
|
|
|
I just started learning how to use C++ and I have a program problem. I thought that I completed the program correctly, but it keeps saying that I have errors, and I don't know why. Below I have what the program is about and my code.
About the program: AG Enterprises has sales outlets in 5 different regions numbered from 1 to 5. Write a program that calculates and displays the total amount sold in each region. Use a counter-controlled while loop to count the regions. Use a nested while loop to allow the user to enter the sales for a given region. Output the total sales for the region as soon as the inner loop stops.
My code:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
double sales = 0.0;
double totRegSales = 0.0;
for (int region = 1; region < 6; region = region + 1)
{
cout << "First sales amount for Region" << region << ":";
cin >> sales;
do
{
totRegSales = totRegSales + sales;
cout << "Second sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
do
{
totRegSales = totRegSales + sales;
cout << "Third sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
do
{
totRegSales = totRegSales + sales;
cout << "Fourth sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
do
{
totRegSales = totRegSales + sales;
cout << "Fifth sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
cout << "Region " << region << "sales: " << totRegSales <
|
|
|
|
|
There are no errors, this code compiles fine, assuming the #include is iostream.
do
{
totRegSales = totRegSales + sales;
cout << "Second sales amount for Region" << region << ":";
cin >> sales;
} while (sales > 0);
This code has me confused - you're saying that the user needs to keep entering a sales value until they enter 0. Is that really what you want, to force the user to always enter zero ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
no i don't want the user to keep entering zero, do you have any suggestions? and i think it is include iostream, right?
|
|
|
|
|
Get rid of the stupid while loop, or reverse it if you want to stop zero being entered.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Atptour wrote:
...but it keeps saying that I have errors...
Care to share them with us?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi, You've not implemented it as required in the program specs.
The specs say five regions, numbered 1 to 5 but don't say anything
about how many outlets are in each region.
Secondly they ask for an out "counter controlled while loop" : you have
implenented a "for" loop.
Thirdly they ask for a nested while loop to handle sales outlets.
You have (probably incorrectly) assume five outlets per region
and implemented five seperate while loops, one for each assumed outlet
and each of which will only accept zero (or a negative number) as a
sales amount (if sales > 0 the loop will keep asking until zero or
less is entered)
In the absense of a defined number of outlets per region you'll
have to allow the user to end the input (for that region) by
for example entering a zero amount.
You should also probably get used to using the use c++ incrementers
e.g.
Outlet++; and
RegionSales += Sales;
instead of
Outlet = Outlet + 1; and
RegionSales = RegionSales + Sales;
So the final code snippet will be something like :
(untested)
int Region;
int Outlet;
double RegionSales;
double Sales;
Region = 1;
while ( Region <= 5 ){
cout << "Region " << Region << endl;
Outlet = 1;
RegionSales = 0.0;
do {
cout << "Enter sales for outlet" << Outlet << " (enter 0 for next region) : " ;
cin >> Sales;
RegionSales += Sales;
Outlet++;
} while (Sales != 0.0);
cout << "Region " << Region << " sales total : " << RegionSales << endl << endl;
Region++;
}
cout << "End of Program" << endl;
Steve T
|
|
|
|
|
I have three fields that I validate once I press enter or when I click or tab to a different control in the window. It works fine when I press enter because it actually sets the focus on the field that it just validated if an error was thrown. Tabbing or clicking to another control sends a message but it does not set the focus back to the control. When I insert SetFocus() on the control it causes an infinite loop because it acts as if the focus for that other control I just clicked or tab to was lost. How do I intercept the focus so that it sets it back to the control it just validated. Here is my code below:
BOOL CSelectPlatform::OnCommand(WPARAM wParam, LPARAM lParam)
{
UINT notificationCode = (UINT) HIWORD(wParam);
if((notificationCode == EN_KILLFOCUS) ||
(notificationCode == LBN_KILLFOCUS) ||
(notificationCode == CBN_KILLFOCUS) ||
(notificationCode == NM_KILLFOCUS) ||
(notificationCode == WM_KILLFOCUS)) {
CWnd *pFocus = CWnd::GetFocus(); // call to a static function
// If we are changing the focus to another control of the same window...
if(pFocus && (pFocus->GetParent() == this))
{
if(pFocus->GetDlgCtrlID() != IDCANCEL)
ValAndSubmit(LOWORD(wParam));
}
}
return CFormView::OnCommand(wParam, lParam);
}
BOOL CSelectPlatform::ValAndSubmit(int DlgCtrlID)
{
BOOL bIsOk = FALSE;
CString Error;
CStn st;
CString str;
Error.Empty();
UpdateData(TRUE);
switch(DlgCtrlID)
{
case IDC_FILE:
if (m_file.IsEmpty())
{
Error = "Please enter a filename";
//GetDlgItem(IDC_FILE)->SetFocus(); //causes infinite loop
}
break;
case IDC_ITEM1:
if (m_item1.IsEmpty())
Error = "Please enter item number 1.");
break;
}
if(!(Error.IsEmpty())) {
MessageBox(Error);
}
|
|
|
|
|
If this CSelectPlatform window is a modeless property page, or a modeless dialog being used to host other controls and placed wholesale in another dialog (like a composite control), you might be able to solve the problem by setting the "Control Parent" style on the dialog window.
Oh, and NEVER do validation on KillFocus...! It is very hard to get workable, let alone right. They often do dumb things like trapping the user, leaving them unable to click [Cancel] without tripping the validation. Which means you have to write more code, to handle that situation, and then handle top-level window switches, etc.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi there,
I am trying to set the "default device" for sound playback and recording, ie the one that you see in the combo box if you look at the Audio tab under Control Panel->Sounds and Audio. I can get the current default device by using mixerGetID but I don't know how to change it. Does anyone know how?
|
|
|
|
|
I have a modal dialog box, which i open from another application. i can move the dialog box to any position I like. After I close it and open it again, I want the dialog box to open in the position where it was last closed. Please help me on how to accomplish this.
Thanks a lot
|
|
|
|
|
Save the dialog's coordinates when you close the dialog, restore them when you display the dialog. See GetWindowRect() and MoveWindow() . Call the former in your OnOK()/OnCancel() handler(s) and the latter in OnInitDialog() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am carrying out an ActiveX. I have a variable COLORREF in one of the page of Properties...and I want to use it in the .cpp that controls the ActiveX...how can i send this variable?
Thanks
|
|
|
|
|
you can use extern keyword for sharing variable between files!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi i'm trying to build a ms access database controller using visual c++ using the ado format. This also has to have client sever using ip addresses. does any one have any example code of a working system?
or a tutorial to follow to conplete this?
regards
|
|
|
|
|
DOes anyone of you know about the C++ bulider and its Client server Suit. I have got C++ builder 1997 edition but there is no serversocket and clientsocket item in the internet component tool kit. Plz help me out from where to download them ? or from where to activate them?
|
|
|
|