 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
hey.....i have searched alot about c graphics and till now don't get any helpful information.
so i want to know some sites which can provide data about c graphics...basically i want to learn this....so do me a favor
|
|
|
|
 |
Because it is difficult and wastes time for modifying the controls position in xml file directly.
Is anyone know how to design a good one as visual studio that cat drag and drop controls?
|
|
|
|
 |
yu-jian wrote: Is anyone know how to design a good one as visual studio that cat drag and drop controls? Yes, I'm sure someone out there has the ability.
"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 all,
First of all, I would like to apologize for posting this question in the C++ forum as it deals with Classic VB (VBA) ... The reason I posted here is because I can't get an answer (not even a hint) in the VB/VBA foums ... I searched the web extensively but without any luck
I hope you guys can ,at least, point me in the right direction
Problem:
I am trying to control the Undo/Redo Stack in excel but I can't seem to get a pointer to the UndoManager Interface in the ppv out argument when calling the QueryService Method .. it always returns Nothing ..
I hope someone can tell me what I am doing wrong .. I think the "SID_SApplicationObject" is not the right SID for what I am trying to achieve
Note : I am using the olelib.tlb
Code :
Sub Test()
Dim pUnk As olelib.IUnknown
Dim IServiceProvider As olelib.IServiceProvider
Dim IID_IServiceProvider As olelib.UUID
Dim IID_IOleUndoManager As olelib.UUID
Dim SID_SApplicationObject As olelib.UUID
Dim ppv As IUnknown
CLSIDFromString IIDSTR_IServiceProvider, IID_IServiceProvider
CLSIDFromString "{0C539790-12E4-11CF-B661-00AA004CD6D8}", SID_SApplicationObject
Set pUnk = Excel.Application
pUnk.QueryInterface IID_IServiceProvider, IServiceProvider
IServiceProvider.QueryService SID_SApplicationObject, IID_IOleUndoManager, ppv
End Sub
Any help will be much appreciated
Regards.
|
|
|
|
 |
jaafar tribak wrote: First of all, I would like to apologize for posting this question in the C++ forum as it deals with Classic VB (VBA) ... The reason I posted here is because I can't get an answer (not even a hint) in the VB/VBA foums ... I searched the web extensively but without any luck I do not see where you've asked this question in the VB forum.
"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,
I did ask similar questions in the VB and COM forums before and in other websites as well .. but these rather difficult questions often remain ignored or without a propper solution .. I thought VC programmers were more confortable with these type of in depth subjects.
The very few vb lines in the above code snippet should be easy to understand by non vb programmers .. I hope that anyone fmiliar with ole/com would hopefully be able to give me (at least) a rough hint
Regards.
|
|
|
|
 |
I am starting my application by a Service. Now When I want to save a
file, I tried using CFileDialog. but when ever I select "desktop" it
prompts a message as "C:Windows\system32\config\systemprofile\desktop"
refers to location that iss unavailable. It could be hard drive on this
computer, or on a network... "
I checked that "C:Windows\system32\config\systemprofile" is available
but there is not desktop directory inside it.
|
|
|
|
|
 |
Sorry I didnt knw abt this
|
|
|
|
|
 |
Hi,
I'm integrating some some WPF controls into a MFC dialog box.
One of the control is a media player that shows live video.
The second one is a label that shows the current video time.
What I need is to have is the label on top of the media player. The label should only display the time, so its background needs to be transparent.
Right now, I have the video player running fine inside the dialog box, but I am unable to have the time displayed as I wish. It just overlap the video player.
Both WPF components were creating by following instructions from this link.
https://msdn.microsoft.com/en-us/library/ms742522(v=vs.110).aspx#hosting_a_wpf_page[^]
I try to set the label with a transparent background.
timeLabel->Background = gcnew System::Windows::Media::SolidColorBrush (System::Windows::Media::Colors::Transparent);
But the label background is shown black.
I also try to set the Transparent flag of the MFC CDialog to true, but it didn't have any effect.
How can I that fixed?
Do I need to set up something special when I instantiate the WPF controls?
Do I need to call some functions from inside the MFC dialog box?
Thanks,
Alain Migeon
|
|
|
|
 |
Member 8833981 wrote: I try to set the label with a transparent background.
timeLabel->Background = gcnew System::Windows::Media::SolidColorBrushSystem::Windows::Media::Colors::Transparent); This looks like Managed code. Might try the other forum.
"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
|
|
|
|
 |
Thanks for suggestion.
I have just done so. But I'm not sure that the answer to my problem is inside the WPF part.
It can also be in the MFC one.
|
|
|
|
 |
Hi,
I want to download file from a given URL. I am using URLDownloadToFile() function for this purpose, but I am not getting the actual file. When I try to run the file, it throws an error.
As an example, If I download MSVS 2010 service pack 1 from Microsoft's website, the file size will be 795KB. But if I download using URLDownloadToFile() function passing the url and file name, downloaded file size will be 99 KB.
Is there any method to download an exe from a URL in C++.
Any help wll be appreciated.
Regards,
mbatra
|
|
|
|
 |
Which URL?
You must pass the complete URL to the file. When browsing MS for downloads, they are often provided by a confirmation page that will start the download. If you pass that URL, wou will download the web page content. On such pages you will usually find a link to the real file if the download does not start after some time.
|
|
|
|
 |
mbatra31 wrote: I want to download file from a given URL. I am using URLDownloadToFile() function... How is it being used?
"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 Guys!,
I've been trying to make a simple tracking game but I'm having trouble just setting up the basic game states. I'm hoping to use a finite state machine(FSM) to switch between screens but every article iv read about them is different and sometimes they leave out details, I couldn't understand it properly.
For example if I've two screens , Menu and Game screen. And in game I've to implement states for a simple tracking game. What would be a FSM look like to switch between them.??
|
|
|
|
 |
Member 9350237 wrote: I'm hoping to use a finite state machine(FSM) to switch between screens... What are the game's states? Inputs?
"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
|
|
|
|
 |
Quote: but every article iv read about them is different and sometimes they leave out details, I couldn't understand it properly.
They are different because FSM are widely used, for different purposes.
There are not may details to understand. A finite state machine is a rather simple stuff. You should understand your scenarion, though.
By wild guess, you could do something like (or go with a more OO approach)
struct FSMData
{
FSMState state;
};
void update_fsm(FSMData & fsmd)
{
switch(fsmd.state)
{
case STATE_MENU:
handle_menu(fsmd);
break;
case STATE_GAME:
handle_game(fsmd);
}
void handle_menu(FSMData & fsmd)
{
if ( userSelection() == PLAY_GAME)
{
fsmd.state = STATE_GAME;
return;
}
}
void handle_game(FSMData & fsmd)
{
if (userInput() == QUIT_GAME)
{
fsmd.state = STATE_MENU;
return;
}
}
|
|
|
|
 |
Hi Guys,
Thanks for your prompt feedback!!.
I'm still bit confused on how to proceed with FSM.
Basically it's a tracking game using a haptic device as controller.
Game protocol:
There will be a start point and stop(target) point .
When the curser stay at start point for 5sec , it'll start and wait until curser reaches target.
If the curser reaches the target in 10 sec, is the criteria to increment the score.
this will will be the state to handle game. But how to script this these criteria??
|
|
|
|
 |
CPallini has given you a basic example for a FSM - you will understand that we're not here to provide ready solutions. You have formulated your game states - what stops you from extending that sample with that, or, at least trying?
|
|
|
|
 |
Hi
I am getting a number of errors in MFC functions (Using Visual Studio 2012)
can't convert const char [xx] to LPCTSTR when using a literal with " double qoute it
was my understanding that anything with " was a pointer now weather its char * or
LPCTSTR is a different issue however it shouldn't be of type const char[xx]
Thanks
|
|
|
|
 |
Do you have the project set to use the Unicode character set? If so LPCTSTR is equivalent to LPCWSTR , so you cannot convert a char pointer to it.
|
|
|
|
 |
Richard
you did it again !!!!!
|
|
|
|
 |
Thanks. Sadly my flashes of brilliant intuition are getting fewer and further apart these days.
|
|
|
|
 |
Try using TCHAR instead of char , and wrapping string literals in the _T() macro.
"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 prefixed the string with a _T macro
And it compiled
Thanks for your help
I have to re-read and he article
|
|
|
|
 |
In my visual Studio project for character set I choose 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
|
|
|
|