|
In my visual Studio project for character set I choose <not set=""> not sure what that means ansi?
1 byte
The other two choices were Unicode and multi byte
So if Unicode is character representation by 2 bytes. what is multi byte ?
|
|
|
|
|
ForNow wrote: So if Unicode is character representation by 2 bytes. what is multi byte ? See here.
"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
|
|
|
|
|
So if I select for my project setting char set -> not set .... And wrap all of my strings with a _T( macro is that best practice
... Thanks
|
|
|
|
|
Will you show me the full example?
|
|
|
|
|
|
Hello,
I have programmed a MFC utility with some radio buttons on the main window.
When I click on a radio button the BN_CLICKED message is captured by the handler and does some task.
I have seen an unexpected behaviour: when I open another window (hard disk explorer, control panel, speaker volume and also a generic folder) and then I close it, the radio button clicks even I haven't clicked the mouse on the radio button.
I suppose that this is caused by my program's window that get the focus when I close the other window.
How can I block this behaviour?
|
|
|
|
|
This behavior is, or at least used to be, by design. When [de]activating the window, the radio buttons do not know that. All they know is that they got focus, and the behavior for radio buttons is to auto-select on focus.
See the WM_SETFOCUS message here.
"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
|
|
|
|
|
Ok,
I have read the WM_SETFOCUS page and now I disable all the radiobuttons when the window lose focus. This works but it seems a strange solution to me.
I wonder if there is a better way to solve the problem. I want to discard message from radiobuttons when they are launched by focus changes.
|
|
|
|
|
I just put together a dummy MFC app with four radio buttons, and an ON_BN_CLICKED() handler for each. With the app running, I open various other windows and then switch back to it, none of the four handlers are fired. Hmmmm
"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
|
|
|
|
|
Dear David,
they aren't fired because you switch from one window to another without have a focus on radiobutton.
If you click on a radio button with the mouse the radio button gets focus: if you switch frome one window to another you will see that the handlers are fired.
If you never click on radiobutton with mouse this doesn't happen.
|
|
|
|
|
Nope, radio button had focus.
"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
|
|
|
|
|
Does somebody have an idea why will the following happen:
printf("Min Value: %d\n", minValue(root));
printf("Max Value: %d\n", maxValue(root));
// not sure why line below throws segmentation core
//printf("Min Val: %d Max Val: %d\n", minValue(root), maxValue(root));
minValue and maxValue are recursive functions returning the min/max value of a binary tree, when called separately as in lines 1 & 2 they work fine, but when called from the same printf statement I get a segmenation fault in linux.
Thanks!
|
|
|
|
|
Without seeing how minValue() and/or maxValue() are implemented, it'd simply be a guess. Perhaps the functions are not "unwinding" correctly.
"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
|
|
|
|
|
I will paste the code. But they are working fine when they are called individually.
int minValue(TreeNode * root) {
TreeNode * current = root;
if (current == NULL) return -1;
else {
while (current->left != NULL)
current = current->left;
return current->num;
}
}
int maxValue(TreeNode * root) {
TreeNode * current = root;
if (current == NULL)
return -1;
else
{
while (current->right != NULL)
current = current->right;
return current->num;
}
}
And they are called as posted above. One more time, when called individually they work fine.
|
|
|
|
|
Where's the recursion?
"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
|
|
|
|
|
I'm sorry, the recursion is in other functions, not in this one. Do you know why it's not working when they are called together?
|
|
|
|
|
Just a theory, but does the following work:
int min = minValue(root)
int max = maxValue(root));
printf("Min Val: %d Max Val: %d\n", min, max);
"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
|
|
|
|
|
 That works, but I wanted to understand why the other version does not work?
Here is all the code if you want to try.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct treenode {
int num;
struct treenode * left;
struct treenode * right;
} TreeNode;
int recLookup (TreeNode *, int);
int lookUp(TreeNode *, int);
int sizeRec(TreeNode *);
int maxDepth(TreeNode *);
int minValue(TreeNode *);
int maxValue(TreeNode *);
int hasPathSum(TreeNode *, int);
TreeNode * createNode (int);
TreeNode * insertRec(TreeNode *, int);
TreeNode * buildTree();
void deleteRec(TreeNode *);
void printIncreasing(TreeNode *);
void printPostOrder(TreeNode *);
void printPaths(TreeNode *);
void printPathRecur(TreeNode *, int[], int);
enum { FALSE, TRUE };
int main (void) {
TreeNode * root = buildTree();
printf("Size: %d\n", sizeRec(root));
printf("Max Depth: %d\n", maxDepth(root));
printf("Min Value: %d\n", minValue(root));
printf("Max Value: %d\n", maxValue(root));
printIncreasing(root); puts("");
printPostOrder(root); puts("");
printf("Has path sum 15: %d\n", hasPathSum(root, 15));
printPaths(root);
printf("Min Val: %d Max Val: %d\n", minValue(root), maxValue(root));
deleteRec(root);
return 0;
}
void printPaths(TreeNode * root) {
int path[10];
int pathLen = 0;
printPathRecur(root, path, pathLen);
}
void printPathRecur(TreeNode * node, int path[], int pathLen) {
if (node == NULL) return;
path[pathLen] = node->num;
pathLen++;
if (node->right == NULL && node->left == NULL) {
int i;
for (i = 0; i < pathLen; i++)
printf("%d ", path[i]);
puts("");
}
else {
printPathRecur(node->left, path, pathLen);
printPathRecur(node->right, path, pathLen);
}
}
int hasPathSum(TreeNode * root, int num) {
TreeNode * current = root;
if (current == NULL)
return num == 0;
else {
int n = num - current->num;
return
hasPathSum(current->left, n) ||
hasPathSum(current->right, n);
}
}
void printPostOrder(TreeNode * root) {
TreeNode * current = root;
if (current == NULL) return;
printPostOrder(current->left);
printPostOrder(current->right);
printf("%d ", current->num);
}
void printIncreasing(TreeNode * root) {
TreeNode * current = root;
if (current == NULL) return;
printIncreasing(current->left);
printf("%d ", current->num);
printIncreasing(current->right);
}
int minValue(TreeNode * root) {
TreeNode * current = root;
if (current == NULL) return -1;
else {
while (current->left != NULL)
current = current->left;
return current->num;
}
}
int maxValue(TreeNode * root) {
TreeNode * current = root;
if (current == NULL)
return -1;
else
{
while (current->right != NULL)
current = current->right;
return current->num;
}
}
int maxDepth (TreeNode * root) {
if (root == NULL) return 0;
else {
int lDepth = maxDepth(root->left);
int rDepth = maxDepth(root->right);
if (lDepth > rDepth) return (lDepth + 1);
else return (rDepth + 1);
}
}
void deleteRec(TreeNode * root) {
if (root == NULL) return;
else {
deleteRec(root->right);
deleteRec(root->left);
free(root);
}
}
int sizeRec (TreeNode * root) {
if (root == NULL) return 0;
else
return 1 + sizeRec(root->right) + sizeRec(root->left);
}
TreeNode * buildTree() {
TreeNode * root = insertRec(root, 4);
root = insertRec(root, 3);
root = insertRec(root, 6);
return root;
}
TreeNode * insertRec (TreeNode * node, int num) {
if (node == NULL)
return createNode(num);
else {
if (num <= node->num) node->left = insertRec(node->left, num);
else node->right = insertRec(node->right, num);
}
return node;
}
TreeNode * createNode(int num) {
TreeNode * newNode = (TreeNode *) malloc (sizeof (TreeNode));
newNode->num = num;
newNode->right = NULL;
newNode->left = NULL;
return newNode;
}
int lookUp(TreeNode * node, int num) {
while (node != NULL) {
if (node->num == num) return TRUE;
else {
if (num < node->num) node = node->left;
else node = node->right;
}
}
return FALSE;
}
int recLookup (TreeNode * node, int num) {
if (node == NULL)
return FALSE;
else {
if (node->num == num) return TRUE;
else {
if (num < node->num) return recLookup(node->left, num);
else return recLookup(node->right, num);
}
}
}
|
|
|
|
|
In buildTree() , change the first statement to:
TreeNode * root = insertRec(NULL, 4); As you had it, root was being used without having been initialized.
"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
|
|
|
|
|
|
Good evening.
I want to know the cpu temperature sample code.
I want something that is written in Visual C ++ code.
Wait a minute you know you had one answer or experience.
Thanks.
|
|
|
|
|
|
I can give you some pointers (no pun intended) using WMI.
"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
|
|
|
|
|
Hello,
I have a namespace and class defined inside a cpp file (say x.cpp ). I want to declare this class as 'friend' inside another header (say y.h), but the header won't recognize the namespace.
Now, when I put the namespace in another header (x.h) and include it in y.h, I get a re-definition error ( also in x.cpp ). I can't remove the namespace definition from x.cpp, since it has been put together by a framework for me, and I won't be able to use the framework otherwise.
Does this mean I can't declare this class as friend of any other class ?
Regards,
Raj Abhishek
|
|
|
|
|
Can you post the relevant code snippets? It's hard to tell what's going on from your description.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|