|
Using the MFC Application Wizard to create the project, you opted for Single Document, correct? On the Generated Classes screen, you could have CListView as the base class for the view.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi,
thank you very much, it works , my first listview
Now i can extend my App an learn more
Best regards
Arrin.
|
|
|
|
|
Academic question.
<b>Which do you prefer</b> - using preprocessor directive #define to replace case state - example "case 0:" with #define NORTH 0 and code "case NORTH:" or use enum?
Here is a sample code using enum:
Enumerated variables have a natural partner in the switch statement, as in the following code example.
#include <stdio.h>
enum compass_direction
{
north,
east,
south,
west
};
enum compass_direction get_direction()
{
return south;
}
/* To shorten example, not using argp */
int main ()
{
enum compass_direction my_direction;
puts ("Which way are you going?");
my_direction = get_direction();
switch (my_direction)
{
case north:
puts("North? Say hello to the polar bears!");
break;
case south:
puts("South? Say hello to Tux the penguin!");
break;
case east:
puts("If you go far enough east, you'll be west!");
break;
case west:
puts("If you go far enough west, you'll be east!");
break;
}
return 0;
}
|
|
|
|
|
|
As already answered, enum is better.
One advantage is that modern compilers can throw a warning when not all enums are handled by the switch statement. So you will be noticed when you forgot to handle a newly added definition.
|
|
|
|
|
enum......
Preprocessor directives can make troubleshooting and reading your code tricky, not worth going down that route unless you don't have alternatives, in this case, you have a perfectly viable solution with an enum.
|
|
|
|
|
<pre lang="Thanks for all replies, I have implemented basic code in SAM3x8E processor - Arduino Due and it works as expected
Thanks
// test input assigment array
#define MAX_INPUT 32
int Input[MAX_INPUT] = {42, 2, 3, 4, 6, 7, 8}; // TODO assign real
volatile byte bInputStateArray[MAX_INPUT]; // state machine array
// test using enum
enum State
{
LED_on,
LED_off,
TEST
};
volatile enum State State_Array[MAX_INPUT];
do
{
switch (State_Array[iInputPin])
{
case LED_on:
{
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("case LED_on ");
#endif
#endif
State_Array[iInputPin] = LED_off;
break;
}
case LED_off:
{
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("case LED_off ");
#endif
#endif
State_Array[iInputPin] = TEST; // illegal case test
break;
}
case NOT_IMPLEMENTED:
{
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("case LED_off ");
#endif
#endif
State_Array[iInputPin] = TEST; // illegal case test
break;
}
default:
#ifdef DEBUG
#ifdef LCD_OUTPUT
Utility_LCD_Process("Invalid case ");
#endif
#endif
}
} while (true);
"></pre>
One more question - since the state is changed using interrupt it needs to be declared as volatile.It compiles with "volatile enum..." so it should be correct syntax, but I cannot test it as yet - the hardware is not ready, but I will try to emulate the interrupt.
AM I on the right track?
-- modified 22-Jun-15 21:55pm.
|
|
|
|
|
No you don't have to declare enum volatile, and the compiler should give you error. This because you are creating an enumerated series of constants and they can't change.
You must declare volatile your input variable, because this is the one that changes under interrupt. You must do this to advice the compiler to take care when optimizing code to make no assumptions on its value. If you don't there will be cases in which the compiler will assume that the variable is in a specific condition and will omit some code or use an old value.
|
|
|
|
|
Thanks,
the "problem" is that Arduino IDE "compiler" is so "automated" AKA stuff is hidden from user.
It did not complain when I tested this base code.
At present the input "pins" array is not volatile and I'll change that.
I have a small additional challenge implementing the ISR ( interrupt service routine).
The interrupt code involves callback and is defined as Arduino API.
The ISR does not accept any parameters , consequently each interrupt process implementation has to have its own ISR. So in theory the input ( variable ) is processed only in one place.
It is convoluted mess and I am working on it.
But I needed the basic state machine to work first.
SO far so good.
|
|
|
|
|
Somewhat unrelated to your original question but........
REMOVE ALL THOSE #defines!
That is some ugly code! If you need a #define on a print function, do it once with a macro and not every single place you want to use that function.
#ifdef DEBUG
#define UTIL_PROC(X) Utility_LCD_Process((X));
#else
#define UTIL_PROC(X)
#endif
case LED_on:
{
UTIL_PROC("case LED_on")
State_Array[iInputPin] = LED_off;
break;
}
|
|
|
|
|
Good suggestion, however I did moved the #ifdef / #endif to the function itself so it does <b>look</b> cleaner.
Actually - is the #else necessary?
|
|
|
|
|
If you're using my method, yes... otherwise the compiler will tell you that function is undefined.
|
|
|
|
|
I'd love to hear any feed back regarding design, style and architecture.
You can find the source at http://github.com/corvusoft/restbed.
Asynchronous RESTful framework
#include <memory>
#include <cstdlib>
#include <restbed>
using namespace std;
using namespace restbed;
void get_method_handler( const shared_ptr< Session >& session )
{
const auto request = session->get_request( );
size_t content_length = 0;
request->get_header( "Content-Length", content_length );
session->fetch( content_length, [ ]( const shared_ptr< Session >& session,
const Bytes& body )
{
fprintf( stdout, "%.*s\n", ( int ) body.size( ), body.data( ) );
session->close( OK, "Hello, World!", { { "Content-Length", "13" } } );
} );
}
int main( const int, const char** )
{
auto resource = make_shared< Resource >( );
resource->set_path( "/resource" );
resource->set_method_handler( "GET", get_method_handler );
auto settings = make_shared< Settings >( );
settings->set_port( 1984 );
settings->set_default_header( "Connection", "close" );
Service service;
service.publish( resource );
service.start( settings );
return EXIT_SUCCESS;
}
modified 21-Jun-15 10:42am.
|
|
|
|
|
However this is not the appropriate place to post it (please remove).
|
|
|
|
|
Apologies, I was some what confused as to which thread this post would belong. Do you have any suggestions?
|
|
|
|
|
Unfortunately, no (I am confused too).
By the way, I've balanced the downvote.
|
|
|
|
|
Hmmm, the 'delete' button is greyed out?!
|
|
|
|
|
Context: MFC MDI CScrollView app, targeting Windows 7
When handling a WM_GESTURE command, specifically when GESTUREINFO.dwID = GID_PAN, and attempting to call UpdatePanningFeedback() to provide "over-panning" feedback when user attempts to pan beyond the scroll limits, the entire application window moves instead of the client area of the windows handle provided...
UpdatePanningFeedback(m_hWnd, 0, yOverpan, gi.dwFlags & GF_INERTIA);
Does anyone know if there is an alternative way to achieve the effect of the "over-panning" (that visual feedback that seems like your trying to stretch the client area beyond it's limits like a rubberband) only in the client area of the CScrollView window?
|
|
|
|
|
Hi sir need clear a explanation for this problem
(n = 3)??wap for this
1###1
33#33
55555
33#33
1###1
at the place of (#) should come spaces
|
|
|
|
|
Member 11779027 wrote: need clear a explanation for this problem That is a fairly basic logic/counting problem that you should be able to figure out by writing the numbers on paper, and deciding how to calculate the number of digits vs the number of spaces for each value.
|
|
|
|
|
Sir Thanks for your advice Finally done!!! but check it once and report me back if any problem is there in coding
#include<stdio.h>
#include<conio.h>
int main()
{
int num=3;
for(int r1=1;r1<=num;r1++)
{
for(int c1=1;c1<=r1;c1++)
{
printf("*");
}
for(int s1=r1;s1<num;s1++)
{
printf(" ");
}
for(int s1=r1;s1<num;s1++)
{
printf(" ");
}
for(int c1=1;c1<=r1;c1++)
{
printf("*");
}
printf("\n");
}
for(int r2=num;r2>=1;r2--)
{
for(int c2=1;c2<=r2;c2++)
{
printf("*");
}
for(int s1=r2;s1<num;s1++)
{
printf(" ");
}
for(int s1=r2;s1<num;s1++)
{
printf(" ");
}
for(int c2=1;c2<=r2;c2++)
{
printf("*");
}
printf("\n");
}
}
|
|
|
|
|
|
* *
** **
******
** **
* *
|
|
|
|
|
Your loop values are slightly off. You should be counting 1 - 3 - 5 - 3 - 1, and printing the numeric values in each line rather than stars. Your main loops should be something like:
int num = 5;
int index;
for (index = 1; index <= num; index += 2)
{
printf("%d\n", index); }
for (index = num - 2; index > 0; index -= 2)
{
printf("%d\n", index);
}
|
|
|
|
|
Ok sir Thnak's and could you please give some examples to practise in this pattern??
|
|
|
|