|
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?
|
|
|
|
|
I am currently developing a little IE deskband that gives the user the ability to hotswap between proxy settings with the click of a button, the button then changes to the user knows what the current proxy setting is(Green Means Proxy On|Red Means Proxy off). The one problem I am running into is the fact that it is able to determine the proxy setting when I start IE and thus the button is correctly set, but if I manually change the proxy through IE via Tools -> Internet Options -> Connection Tab -> Lan Settings, the button doesn't update. I was wondering if there is anyway I could envoke a ilstener that would be able to notice when I manaully change the proxy and then set the button based on its current setting after said event. Might be a difficult explanation to understand but if anybody is interested please e-mail me if you want further explanation.
|
|
|
|
|
|
Thanks for pointing me in the right direction Gerald. but I can't quite seem to figure out how to exactly write something that would actively monitor for a change in this registry key. Any help with this would be greatly appreciated. I'm not an expert developer so you'll have to bear with me.
|
|
|
|
|
RegNotifyChangeKeyValue monitors the registry key for you. If you use the RegNotifyChangeKeyValue synchronously, then it waits until a subkey has changed before continuing execution. You could use a loop and continue to moniter. If you use RegNotifyChangeKeyValue asynchronously, then you wait on the event instead.
Run the code below. It will wait during the call to RegNotifyChangeKeyValue. Then change your proxy setting through IE and click ok. Then you will see the MessageBox.
#include <tchar.h>
#include <windows.h>
INT WINAPI
_tWinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
INT nCmdShow
)
{
LONG l = 0L;
HKEY hKey = {0};
l = RegOpenKeyEx (
HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
0,
KEY_NOTIFY,
&hKey );
if(l == ERROR_SUCCESS)
{
l = RegNotifyChangeKeyValue (
hKey,
FALSE,
REG_NOTIFY_CHANGE_LAST_SET,
NULL,
FALSE );
MessageBox(NULL, _T("Registry key changed"), _T("Registry key changed"), 0);
RegCloseKey(hKey);
}
return 0;
}
|
|
|
|
|
i have created a 3D world scene and i want it to be in movie (2D)
i tried to do that by Audio Video PlayBack in directX but i get flicker
i tried it also to do that by VMR9 but it takes bitmaps as an input and i have textures so it'll take a time to convert.
I need it in run time. Thanks for your help
|
|
|
|