|
Cillieacc0rd5o4 wrote:
with old C++
What do you mean ? Most of this stuff is C, not C++, that is, NO C++ compiler would treat any of this different. What compiler do you have ?
Cillieacc0rd5o4 wrote:
What u mean that thing on top?
You shouldn't define variables without giving them a default value, and you should define them when you need them, not in a block at the top. It compiles either way, I'm talking about writing *good* code here, not just code that compiles.
Cillieacc0rd5o4 wrote:
The examples had it there.
I'm sure they did. The only thing that matters is that you need else return FALSE, not just else FALSE. The rest is a lesson in good form, not writing code that compiles.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Its a C++ Compiler
I normally do Java. Did like C 10 years ago for 1 month. So pardon me for the nOoB questions.
Well I need it to compile that is understandable.
Written clean, i dont care about that right now. I need it to work first.
And dunno how to integrate the If else inside the switch. Or get it to work. Or what other methods i can use.
|
|
|
|
|
Cillieacc0rd5o4 wrote:
Its a C++ Compiler
Duh. Which one ?
Cillieacc0rd5o4 wrote:
So pardon me for the nOoB questions.
That's completely fine - that's what we're here for.
Cillieacc0rd5o4 wrote:
And dunno how to integrate the If else inside the switch. Or get it to work. Or what other methods i can use.
I've already shown you. Your code should be fine, except the error I pointed out.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I managed to get it to work THnx alot.
Well Visual c++ 6.0 errrr enterprise it hink this sh*t comp uses.
This fool keeps one wanting to add stuff to the program.
And i only have limited Very limited C++ Knowledge.
|
|
|
|
|
VC6 is a decent C++ compiler, I doubt at your level that you'd find any places where it deviates from the standard.
Cillieacc0rd5o4 wrote:
This fool keeps one wanting to add stuff to the program.
Is 'this fool' a lecturer ?
Cillieacc0rd5o4 wrote:
And i only have limited Very limited C++ Knowledge.
I suggest buying a book that starts low and moves slow, like 'teach yourself C++ in 24 hours', and working through it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Nah that fool is from Testing Dept. Where i work at. I work in EDV Taking care of Networks of the company. I accationally write Java Code. Got temporarly assigned with this Fool to write a Programm For a Test Machine Robot. And it needs to be C++ a Language that i am learning as i write the project. So far i got 8 pages of codes in 1 week and 3 days. And this forum has helped me great deal on how the basic of C++ work =).
Worse thing that guy dont know how to program at all.
But yeah thanks guys!!!
PS: Got 2 C++ Books Here only one is usefull. the way teh other is written i dotn get it.
|
|
|
|
|
K all fixed but this if you can help.
term does not evaluate to a function
Error executing cl.exe.
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
{
case DLL_PROCESS_ATTACH:
int ScoMSGetAS();
unsigned short error;
unsigned short state;
double value;
>>>>>> error = SCO_AS6();
if (error != SCO_ERR_OPEN_DRIVER)
{
return ScoOpen();
}
else return FALSE;
}
break;
only prob left dun understand that though
|
|
|
|
|
Cilllieaac0rd wrote:
int ScoMSGetAS();
What is this meant to be ? It looks like a forward declaration of a function, which means it's in the wrong place. If ScoOpen returns an int then you need
int myInt = ScoMSGetAS();
if ScoMSGetAS is the name of an int you want to declare, then you need
int ScoMSGetAS;
I have to say, most of this stuff, the syntax is the same as Java.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I was trying to use somethign like this.
BTW i Couldnt log on before but its me again.
I am trying to use else if when the AS_SCO6 is executed it will give 0-5 digit depending on what error.
and it wanna do if or else for each 0 1 2 3 4 5 or just if 3 else rest.
Dunno the code for it though. cant find any info on t since i dunno what it is called.
{
case variable equals this:
do this;
break;
case variable equals this:
do this;
break;
case variable equals this:
do this;
break;
...
default:
do this
}
|
|
|
|
|
you've lost me entirely here. You seem to have provided a switch statement in what looks like VB, but what are you trying to do here ? If your compiler gave you some errors, then your code is wrong. You didn't say that, you said you didn't understand why there was an if/else inside a switch. Make sure your } do line up and the original code should work fine. Otherwise, if you want something else, explain it. These are all your own functions ? AS_SC06 is yours and you want to act depending on what the return value is ? Then you probably need another switch statement based on the return value. Your brackets will still need to line up in order for it to compile.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Been trying to allign em the entire morning.
Either the cofee is getting to me or this morning shift is making me see things.
On top is the entire switch.
I tryed to include a IF else inside the SWitch.
So depending on the value i get back it suppose to load teh driver or not.
aka if the value comes back to be no driver present it suppose to go ahead and load it. else just leave it alone.
YOu guys helped me before with the Switch stament that works fine now. Thnks alot =)
But i try to put thsi fail save in to block it from loading a driver that is already present. and only load it if its not.
|
|
|
|
|
This works with out the else if inside the switch. with the switch i can figure out how it works.
//
#define STRICT // wg. type checking
#include "windows.h" // wg. MessageBox
#include "stdlib.h" // wg. abs()
#include "usedll.h"
#include "scooter.h"
// damit die Funktionsnamen leserlich exportiert werden
#pragma comment(linker, "/DEF:usedll.def")
void exitfkt(void)
{
MessageBox(NULL,"Unload Dll", "Test", MB_ICONINFORMATION | MB_OK);
}
// Loading of the driver at start of the driver
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
{
case DLL_PROCESS_ATTACH:
int SCO_AS6();
unsigned short error;
unsigned short state;
double value;
error = SCO_AS6();
if (error != SCO_ERR_OPEN_DRIVER)
{
return ScoOpen();
}
else return FALSE;
}
break;
case DLL_PROCESS_DETACH:
atexit(exitfkt);
break;
}
return TRUE;
}
// return not loading driver();
EXP_USHORT TestDriver(void)
{
return SCO_AS6();
}
// Loading of the Driver
EXP_USHORT ItaOpen(void)
{
return ScoOpen();
}
// Unloading of the Driver
EXP_VOID ItaClose(void)
{
ScoClose();
}
// Power on/off for the Vacuum
EXP_USHORT Adaptor(int Status)
{
if(Status == 0)
{
return ScoMSSetVC(SCO_VC1,0);
}
else
{
return ScoMSSetVC(SCO_VC1,1);
}
}
// Power on off for VC2
EXP_USHORT VC2(int Status)
{
if(Status == 0)
{
return ScoMSSetVC(SCO_VC2,0);
}
else
{
return ScoMSSetVC(SCO_VC2,1);
}
}
// Reset all relays back use(CLRREL) command
EXP_USHORT Reset_All(void)
{
return ScoResetAllRelays();
}
// Set relays of the Unicard while set relays stay set
EXP_USHORT Set_Relais(int fl_set)
{
if(fl_set == 0)
{
return ScoUniSetRelay(fl_set,1);
}
else
{
return ScoUniSetRelay(fl_set,1);
}
}
// Reset relays of the Unicard while set relays stay set
EXP_USHORT Reset_Relais(int fl_set)
{
if(fl_set == 0)
{
return ScoUniSetRelay(fl_set,0);
}
else
{
return ScoUniSetRelay(fl_set,0);
}
}
EXP_USHORT Reset_All_Relais(int fl_set)
{
if(fl_set == 0)
{
return ScoUniSetRelay(fl_set,0);
}
else
{
return ScoUniSetRelay(fl_set,0);
}
}
EXP_USHORT VCC(int Number)
{
if(Number == 3)
{
return ScoMSSetVC(SCO_VC3,1);
}
else
{
return ScoMSSetVC(SCO_VC3,0);
}
if (Number == 4)
{
return ScoMSSetVC(SCO_VC4,1);
}
else
{
return ScoMSSetVC(SCO_VC4,0);
}
}
|
|
|
|
|
Cillieacc0rd5o4 wrote:
Been trying to allign em the entire morning.
Use Ctrl+} to match up braces, brackets, and parenthesis.
Cillieacc0rd5o4 wrote:
I tryed to include a IF else inside the SWitch.
What is so difficult about this:
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (some_condition)
mow_lawn();
else if (some_other_condition)
wash_car();
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
It looks like you have a function (SCO_AS6 ) within a function (DllMain ). That's illegal.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I don't know what all the hu-bub is about, of course you can use an if-else statement with in a swich (your code should be working). Unless there is more to your code under DLL_PROCESS_ATTACH that you are not showing us, then you don't need all those extra variables and the if-else can be eliminated, as follows:
BOOL APIENTRY DllMain(
HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
return(SCO_AS6() != SCO_ERR_OPEN_DRIVER);
}
return TRUE;
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Problem : I have a dialog wherein i have a "Main" property sheet and one of the property pages of this sheet have a Tree control and an embedded "SubSheet" property sheet. I wanted to transfer data from one of the embedded "SubSheet" property pages to the tree Control which is in the Outer "Main" property page. Could u help me out in anyways. Is there any way of doing it. I am posting code which is the code in the main property page.
class CSanSettings : public CPropertyPage
{
DECLARE_DYNAMIC(CSanSettings)
public:
CSanSettings();
virtual ~CSanSettings();
// Dialog Data
enum { IDD = IDD_SANSETTINGS };
protected:
CPropertySheet m_SubSheet;
CSanDetails m_SanDetPage;
CAddSwitch m_AddSwtPage;
CScanSubnet m_ScanSubnetPage;
CFabricDetails m_FabricDetPage;
CSwitchDetails m_SwtDetPage;
CTestConnect m_TestConPage;
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CTreeCtrl m_San_Display;
afx_msg LRESULT OnMyCode(WPARAM t1,LPARAM t2);
};
BOOL CSanSettings::OnInitDialog()
{
CDialog::OnInitDialog();
m_SubSheet.AddPage(&m_SanDetPage);
m_SubSheet.AddPage(&m_AddSwtPage);
m_SubSheet.AddPage(&m_ScanSubnetPage);
m_SubSheet.AddPage(&m_FabricDetPage);
m_SubSheet.AddPage(&m_SwtDetPage);
m_SubSheet.AddPage(&m_TestConPage);
m_SubSheet.Create(this, WS_CHILD | WS_VISIBLE, 0);
m_SubSheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);
m_SubSheet.ModifyStyle( 0, WS_TABSTOP );
CRect rcSheet;
GetDlgItem( IDC_SHEET2 )->GetWindowRect( &rcSheet );
ScreenToClient( &rcSheet );
m_SubSheet.SetWindowPos( NULL, 20, 160, 0, 0,
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );
// return TRUE;
// return TRUE unless you set the focus to a control
}
Hemanth
|
|
|
|
|
In my opinion, you should share a pointer on your TreeControl in both property sheets. The pointer can be accessed from every property page using a GetParent() function.
~RaGE();
|
|
|
|
|
Hello folks,
I need some help with my C++ program, hope you can offer it to me.
I used fout<<time(0); to write the actual time to a file.
Now I need to transform the string which I retrieve from the file, back to time_t type, to be able to use the difftime function to calculate the time difference between time1 and time2 in seconds.
The problem is, that I am not able to test the time function at the moment, so it might also be possible to use difftime without transformation. I hope you can tell me, if this is so.
Hopefully I managed to describe my problem in an understandable way, as I am no native english speaker.
Best Regards, Jun_Misugi
|
|
|
|
|
Jun_Misugi wrote:
Now I need to transform the string which I retrieve from the file,
It is not written as a string so why retrieve it as such? Retrieve the value just like it was written, as a time_t type? Then you can easily subtract the two to find the difference.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Ok. Then I got the reference wrong. Thanks for your help.
|
|
|
|
|
Jun_Misugi wrote:
Then I got the reference wrong.
What reference?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Can anybody tell me how to place an icon in status bar and replace it with a new one at runtime?
|
|
|
|
|
|
Hi Masters,
I am trying to specify the output tray (output bin) for specific printer. It is quite easy to specify the input tray but I couldn't find the way to specify the output tray.
I have already look at the documentation of the printer. It says nothing about choosing the output tray programmatically. I know that I can choose the printer output tray via PCL. However, in my case, I need to use Win32 API since not all printer support PCL.
Thank you for any helps in advance
Cheers...
|
|
|
|
|
I have a program that is CAtlExeModuleT - derived. It is a dialog app, that is, it creates a dialog from CAtlExeModuleT<cmymodule>::Run() that does everything.
When I Alt+Tab through the task list, my app has a null icon (I have set the icon for the dialog). I would like to set that icon.
My first attempt was to use EnumWindows() and SetClassLongPtr() in the startup code, but that failed because my app does not have a window, only a dialog.
How can I set that icon?
Thanks very much.
N-o-R
riley dot dewiley at gmail dot com
|
|
|
|