i found that i didn't add the image to my project. it's just an image which exists somewhere in my HDD. but, the matter is that i don't want to put a static image there. consider a program which is written and doesn't intend to know what is the image. by clicking on the default image a file open dialog must be opened from which user may select the image he/she wants to be shown in the Image control. also consider a case in which the image must be made dynamically. maybe something like a simple MSPaint. user may just draw lines or put points. it's enough that the image not to be static anymore. what can i do in such cases? thx
ilostmyid2
Posts
-
901130 - Image is not displayed -
901130 - Image is not displayedin the following XAML:
the image is displayed in design mode, but is not displayed in runtime, neither in browser nor out of browser. why it may be? P.S. replace the face with colon d!
-
900520 - VC6 vs VS 2010ok, i found it at last. it's enough to replace &a and &b in the initialization of m_values with &A::a and &A::b. thank u Maximilien. i couldn't figure it out sooner.
-
900520 - VC6 vs VS 2010let's continue with a completed code. i wonder that it really works and it's not going to be a mistake or bug of the compiler:
#include "StdAfx.h"
using namespace std;
class A
{
public:
struct Info
{
int A::*a;
};
int a, b;
static Info m_values[];void f();
};
A::Info A::m_values[] = {&a, &b};
void A::f()
{
int a = this->*(m_values[0].a);
int b = this->*(m_values[1].a);
cout << "m_values: " << a << ", " << b << endl;
}void f()
{
A a1, a2;
a1.a = 10;
a1.b = 11;
a2.a = 20;
a2.b = 21;
a1.f();
a2.f();
}the output is: m_values: 10, 11 m_values: 20, 21 so how does vc6 implements this and what's the equivalent code in vs2010? thx
-
900520 - VC6 vs VS 2010i created this topic for this, to get help to understand what does the code do!
-
900520 - VC6 vs VS 2010as i mentioned b4, i myself don't know what the code is supposed to do too. i just see that vc6 can realize it and guess the writer has written the code in the way it understand. i just need to know what does the code do so that i may port it to vs2010 to do the same behavior. that's all.
-
900520 - VC6 vs VS 2010the code compiles only in vc6. in vs2010 i get an error indicating that the array cannot be initialized with &a and &b because they must belong to an instance of A and this is reasonable. i need to know whether it's a bug of vc6 compiler or the vc6 compiler interprets it and makes in sense in a way that vs2010 doesn't.
-
900520 - VC6 vs VS 2010indeed it's not a code of mine or my friend. this a piece of a large project which my friend uses. they have to port the whole project containing the code from vc6 to vs2010. so, i'm not the writer and i don't know what has been the aim. eg. int is my replacement to CButton for simplification. the structure is not changed though.
-
900520 - VC6 vs VS 2010thanx 4 ur reply, but what's the difference between these two? a and b are not static data members to be pointed to. there must exist an instance. if u mean the offset of them from the beginning of the class instance, we should use offsetof() in such a case which is completely different from this.
-
900520 - VC6 vs VS 2010hi porting a project from VC++ 6 to VS 2010 caused i find a mistake. in the following code i had written:
#include "StdAfx.h"
class A
{
public:
struct Info
{
int A::*a;
};
int a, b;
static Info m_values[];
};A::Info A::m_values[] = {&a, &b};
...
indeed this is a simplified of what i had. VC 6 doesn't cause error! 1. how it fill m_values? i found that they're filled with 0 and 4! 2. is it essentially a bug of VC against VS 2010? how does it interpret this code? how can it assign m_values with non-instantiated member variables?! does it have a different interpretation when it sees this? i didn't try earlier versions of VS. 3. what's the difference between int A::* and int *?! i know that they're different when we're talking about global functions and member functions. but what about when we're talking about int's? thx
-
891130 - capturing an image from a cameraApplication A was using C.dll as an interface for camera. C.dll was and is erroneous. Sometimes it throws exceptions and causes the application to crash. Since the application is intended to be running always in the platform and is responsible for many things as well as handling cameras, we decided to use in indirect method for the application to use the camera. The plan was to separate the dll from the application. Another application got responsible for getting involved with sending the appropriate commands to the camera via the dll and in another side be in communication with the application. We call it server. The application is now a client for it. The communication between these two separate processes is established via a named pipe. I've tested this link and it works fine. Now the problem is that after starting the camera I use the following code to capture an image:
bool CCamera::CaptureImage(LPCSTR i_lpszBMPFileName)
{
if (m_hWnd &&
capGrabFrameNoStop(m_hWnd) &&
capFileSaveDIB(m_hWnd, i_lpszBMPFileName))
return true;
return false;
}The m_hWnd is created with this code:
m_hWnd = capCreateCaptureWindow(m_sName, WS_CHILD|WS_CLIPSIBLINGS, 0, 0, 160, 120, i_hwndParnt, 0xffff);
i_hwndParent in both cases (before separating the application and after it) is obtained with the following code:
i_hwndParent = CreateWindow("STATIC", "parent", WS_POPUP, 0, 0, 20, 10, NULL, NULL, NULL, NULL);
Before changing the method to a client/server method, in CaptureImage everything was working fine. Both capxxx macros did their job and returned with true or false. But now, the program control remains inside them and the if statement is not evaluated until I stop the camera. After stopping the camera these macros return with true. It causes the application to remain in the CaptureImage function and never returns until the camera is stopped. I wondered what might be different in two methods. I couldn't realize why the macros don't return. Any idea? Thx
-
891011 - nested groups in a property gridhi how can i have nested groups in a CPropertyGridCtrl without increasing indent? let me depict what i'm going to do. i've a ready program with the following output: original[^] i tried to create the same output with the following code:
void AcItemPropertyPane::pr_appendLinkProp(CMFCPropertyGridProperty *pGroup, const AsLink &link)
{
CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty("Coordinate for Goto", 0, TRUE);
CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty("Address X", (_variant_t) link.col, " ");
pProp->EnableSpinControl(TRUE, 0, 99);
pGroup2->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty("Address Y", (_variant_t) link.row, " ");
pProp->EnableSpinControl(TRUE, 0, 9);
pGroup2->AddSubItem(pProp);
pGroup->AddSubItem(pGroup2);
pProp = new CMFCPropertyGridColorProperty("Color of Goto Route", (_variant_t) link.color, NULL, "Goto line color change");
pGroup->AddSubItem(pProp);
}void AcItemPropertyPane::pr_initADSensorPropList(const AsItemSpec &is)
{
d_wndPropList.RemoveAll();
CMFCPropertyGridProperty *pGroup = new CMFCPropertyGridProperty("AD Setup");
CMFCPropertyGridProperty *pProp = new CMFCPropertyGridProperty("A/D port", " ", "A/D port setup");
pGroup->AddSubItem(pProp);
pGroup->AddSubItem(pr_newFuncProp(is.func));
pProp = new CMFCPropertyGridProperty("Compare variable/value", " ", "When jump is compare to Input value (0-255).");
pGroup->AddSubItem(pProp);
pr_appendLinkProp(pGroup, is.link);
d_wndPropList.AddProperty(pGroup);
}(pr_initADSensorPropList is called). but it resulted in the following output: mine[^] there's also a difference in the original color property and mine. also separator in coordinate differ (; with ,) how can i make mine appear the same as the original one? thank u
-
890927 - Invalid Input Format exception in sscanf_s1. i found the way. indeed, the default implementations of converting text into value which is done in the virtual function TextToVar of a CMFCPropertyGridProperty and converting value into text which is done in the virtual function FormatProperty use m_strFormatFloat for float types and m_strFormatDouble for double types and we may override this behavior. so it's enough to leave m_strFormatFloat as is and override method FormatProperty in a derived class.
-
890927 - Invalid Input Format exception in sscanf_syeah, good idea, although i get my answers mostly from codeproject rather than MS! and u mean there's really no option other than replacing codes?
-
890918 - keystroke seems not to generate the desired commandi couldn't find TranslateMessage! it seems to be an API function, not belonging to any class. TranslateMessage of what class u mean?
-
890927 - Invalid Input Format exception in sscanf_sall of the problem is that i like to least code, otherwise i would code another CSpinCtrl class as well as another CMFCPropertyGridProperty! 2. i've also to set steps of up and down arrows to 100 instead of increment and decrement. i prefer to use a different class than the original CSpinCtrl instead. 1. i tried to explain accurately! the problem is that the format strings for sprintf_s and sscanf_s do not process similarly. dot in the format string for sscanf_s has no sense while in the format string of sprintf_s has meaning. since the format string for type double or float is only one for both presenting the value or evaluating it, i've to replace the class with another one which i alter by code rounding it and this is what exactly i wanted to avoid. 2. it's the same for a spin ctrl. instead of calling EnableSpinControl for the property, i've to define another function to create another spin ctrl class with the desired functionality and this is also what i wanted to avoid. i wonder how such great class are coded with such fool limitations! thanx anyway
-
890927 - Invalid Input Format exception in sscanf_sthank u for the description. the problem is that format strings for sprintf_s and sscanf_s differ. for sscanf_s including a . in format causes Invalid Input Format exception in anyway. as u mentioned, the input string is read by the number of bytes specified in the format b4 f and the chunk string is processed to be converted into a float. while in sprintf_s . has meaning. %4.2f for example means that the output string must contain at least 4 characters and exactly 2 digits after decimal point. if it be needed this may increase, eg. %2.2f or even %1.2f lead to the same output 0.02 or even 123456789.00. this is while we has only one format for a grid ctrl, not two separate formats, one for sprintf_s and one for sscanf_s. as i said b4 it's stored in CMFCPropertyGridProperty::m_strFormatFloat or CMFCPropertyGridProperty::m_strFormatDouble. this uniqueness in the source of the problem. now what's ur suggestion? i've also another problem. spin ctrls are designated for integral fields. i need to attach a spin ctrl to a field of type float. for example when i've 12.34 in the field it may get 11.34 or 13.34 with up and down arrows. if i specify it to limit to 20, after 19.34 it gets 20.00 with arrow up. when i specify low limit of zero it gets 0.00 after 0.34 with arrow down. the spin ctrl doesn't expect the input field to be a float while it doesn't contrast with its behavior. so the summary of the two problems are: 1. how can i overcome the uniqueness of floating point fields format in a grid ctrl which is both used for showing and inputting? 2. how can i have a spin ctrl for a floating point input field? thx
-
890927 - Invalid Input Format exception in sscanf_sthank u, i read it, but i couldn't figure out what to choose as format for a floating point variable with read part of variable digits number and floating point of always two digits.
-
890927 - Invalid Input Format exception in sscanf_syes, it works. but since the format is the same as what is used for showing the property (CMFCPropertyGridProperty::m_strFormatDouble), i've to specify the number of digits i want to be shown after the decimal point, so i can't use %lf.
-
890927 - Invalid Input Format exception in sscanf_sin the following code:
double a; sscanf\_s("0.02", "%.2f", &a);
i get Invalid Input Format exception! what's the problem? i also tried %1.2f and %4.2f, but no change.