|
narasingubhanu wrote: Any idea about this? Sorry, no.
Veni, vidi, abiit domum
|
|
|
|
|
hi!!!!
how to modify the size of window , I modify the parameter of CDialog::onCreate(),but it does not work
|
|
|
|
|
You need to provide much more information. Saying "it does not work" tells us very little.
Veni, vidi, abiit domum
|
|
|
|
|
Windows 7, Visual Studio 2008, C++, MFC
Question:
How do we put a control in a group box?
Details:
A group box is dragged placed in the dialog and a control dropped on it. (Static text, check box, and button) When the group box is moved, the control stays put. I interpret this as indicating that the control was not added to the group. I have looked closely at the properties for the group box and the control and have not recognized anything that will accomplish this. What needs to be done to put the control in the group box.
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
Are you thinking of group box maybe in the Visio sense where you 'group' a set of visual objects and then they are treated as one ?
from what I recall, it never did that in MFC - you just referred to the elements of a group box in code slightly differently ? by an index
|
|
|
|
|
I don't know about Visio. After some searching it seems to me that I should be able to drop a control into a group box and have it become part of that group. When the group box is moved, the control moves with it group and stays in the same relative position. Is there some other meaning or use of the term "Group Box" and the control "Group Box."
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
Sorry, worked late into Friday night on a deployment, family stuff yesterday, didnt get back to test this
Ive just tested in VS2005 C++/MFC
Created a new MFC, Dialog based app, edited the dialog - dropped and resized the 'Group Box' COntrol from the ToolBox, then dropped 3 x Radio Buttons into the Group Box.
Then I selected the Group Box, and it moved independently from the Radio Buttons. Only when I contol-Clicked the Group Box, AND each of the Radio Buttons, could I move them all together
bkelly13 wrote: Is there some other meaning or use of the term "Group Box" and the control
"Group Box."
Having a Group Box around the Radio Buttons changes how they are accessed - almost like an array - not 'moving them around the screen' - seems a bit odd, dont know if I took that much notice of all of this years ago when I did MFC
I know someone who actively uses MFC in VS2010 these days, I'll check with him
'g'
|
|
|
|
|
don't lose your time and don't spend lot of effort on an old programs builder , I advice you to use a new software coder like visual studio 2012 or Xamarin or RAD STUDIO XE4.
good luck in coding bro.
|
|
|
|
|
VS 2008 is still a lot better than I am. Just the same, its five years old now. I found VS 2012 Pro via Amazon for about $350 and ordered it. I will see what that does. Does it make the group box work?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
If you are using the win32 dialog builder of VS (for dialog based MFC) then I have bad news. A groupbox is nothing more than simply a visual border with an optional label. It isn't supposed to be the parent of any controls, its not like a panel in modern usable rad gui development tools. You can use a groupbox to visually draw a "border" around a group of controls that are functionally coupled but that's it. Upgrading to VS2012 won't change that. (BTW, have you ever programmed gui using "bare metal" win32?) In my opinion VS2008 is very good but my current favorite is VS2010. They have improved a lot in VS2010 including intellisense and a lot of small bugs. At first touch I didn't really liked VS2012 for some reason...
EDIT: also read this: Group Boxes[^]
|
|
|
|
|
If you want to select a 'group' of controls so that you can move them together, select one of the controls, then ctrl+click several others. You will see them highlighted with the borders of all/each. If you select one by mistake, ctrl+click again. This 'group' handling disappears when you select (click) without either ctrl or shift inside the dialog resource.
If you want to 'group' several controls in the Visio sense, Visual Studio doesn't do that (as other posters have indicated).
Windows 8 is the resurrected version of Microsoft Bob. The only thing missing is the Fisher-Price logo.
- Harvey
|
|
|
|
|
Me either,Perhaps it doesn,t support that
|
|
|
|
|
I am creating an SDI application.
On Start, its title is "Untitled - MyApp".
When i load a file named File1.txt using open button, then its title is changing to "File1.txt - MyApp".
The Problem arise when i want to change the title without loading a file using open button. Can anybody tell me how to set the title of an SDI application.
Thanks in advance!!!
|
|
|
|
|
|
Thanks Richard, I have done the same thing earlier but it did not work.
I think my problem lies in my applications SDI architecture.. might be my Document and View are not connected properly or they are not getting properly registered with CSingleDocTemplate Class.. Please suggest how to check whether i am following my SDI architecture properly.
Thanks.
|
|
|
|
|
puneit4u wrote: Please suggest how to check whether i am following my SDI architecture properly. Read the documentation on MSDN where it is all explained. Alternatively create a new project with the Visual Studio wizard and compare with your project.
Use the best guess
|
|
|
|
|
puneit4u wrote: I have done the same thing earlier but it did not work.
Keep in mind that if you set the title to something, then open a document, the framework sets the title as you describe in your original message.
You can suppress this behavior by overriding a framework method. I don't have VS2010 open right now but you can figure this out by looking at the source.
Windows 8 is the resurrected version of Microsoft Bob. The only thing missing is the Fisher-Price logo.
- Harvey
|
|
|
|
|
I have a safe array of variants I have been working on getting working in c++. I need to pass a safearray of variants with this flags in fFeatures set by default: FADF_FIXEDSIZE, FADF_STATIC, FADF_HAVEVARTYPE and FADF_VARIANT.
Trouble is I have an ATL com dll project (mouse emulator) that wraps another ATL com dll called softhidreceiver.
When I called softhidreceiver I need to pass a safe array of variants but Iam having trouble doing so. Here is an msdn forum post that never got solved but grew so large I just started a new post.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/a54fdef1-6479-41dc-8662-4c615d1dab9e/invalid-safearray-of-variants#be1b5734-9a80-439e-a3dd-32f48d24ab84[^]
Anyone knowledge with safearray of variants? I have not choice in the matter unless someone has a better idea of passing values to queueinputreport?
Heres my current code though so far:
STDMETHODIMP CMMEmulator::sendinputreport(unsigned char inputreport[5], int length)
{
_TCHAR szBuffer[100];
_stprintf_s(szBuffer, _T("%i"), inputreport[1]);
MessageBox(NULL,L"value of second byte input report",szBuffer,NULL);
BYTE bSampe[5] = {0x00,inputreport[1],inputreport[2],0x00,0x00};
HRESULT hr = S_OK;
SAFEARRAY *psaData = NULL;
VARIANT HUGEP* pVarArrayData = NULL;
SAFEARRAYBOUND bound;
bound.cElements = 5;
bound.lLbound = 0;
psaData = SafeArrayCreateVector(VT_VARIANT,0,5);
hr = SafeArrayAccessData(psaData, (void HUGEP**)&pVarArrayData);
if (SUCCEEDED(hr))
{
for (long i = 0; i < 5; i++)
{
VariantInit(&pVarArrayData[i]);
pVarArrayData[i].vt = VT_UI1;
pVarArrayData[i].bVal = static_cast<byte>(bSampe[i]);
}
hr = SafeArrayUnaccessData(psaData);
if (SUCCEEDED(hr))
{
piSoftHidDevice1[devindex]->QueueInputReport(psaData,10);
piSoftHidDevice1[devindex]->StartProcessing();
}
}
SafeArrayDestroy(psaData);
return S_OK;
}
jeffery
|
|
|
|
|
If method A calls B and B is to return or provide a CString to A, what is the better way to do this? The declaration for B can look like:
CString B();
Or
Void B( CString &out_string );
I am thinking the latter should be preferred. The former is simpler but it seems to expose its internal data to the caller.
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
Option 1 is the generally accepted method style, unless B needs to return a status value like:
BOOL B( CString &out_string );
Use the best guess
|
|
|
|
|
Any decent compiler with return value optimization will compile about the same machine code from the above method declarations so I would use CString B(); because it looks nicer. The second version seems much like "human optimized" code but its not that terrible. From this example what came to my mind is the usual CString ToString(); method. Its easier to use the first declaration because the second always requires you to declare variables on the stack before the call while the first one allows you to write nicer code, for example you can immediately pass the return value of B() to another function call that receives a string.
Another thing you need to know here: Even if there is no return value optimization in your compiler (Visual C++ has it) CString is a reference counted string that means: It is just a "pointer" to the string data so copying it copies only a pointer and increases then decreases a refcount of the string data when the returned temp refcount-pointer object (CString) is deleted.
|
|
|
|
|
Am I correct in thinking that "return value optimization" self descriptive rather than having a special meaning?
In the first call B, more of a function style, is written as:
CString B( ){ return internal_string }
While the second, more of a procedure style, would look like:
void B( CSrting &some_string );<br />
{ some_string.empty();<br />
some_string = internal_string;<br />
}
That presumes that some_string = internal_string is a copy operation and not a reference operation. Is that presumption true or false?
The first hands out an address within B's space while the second does not. That also means that the caller would have to copy it before doing anything that would change it. I know we can adorn the return value with "const", but still.
Is that logic flawed?
Thanks for your time
If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig_106/
|
|
|
|
|
If you are interested about how optimizations work please use google. You can never expect a compiler to optimize your code at a particular code location but please don't write ugly code just to try to optimize out things prematurely. Whether to make a piece of code manually-optimized and ugly depends on a few factors: The size of the data structure you want to return, the frequency with which the function is being called,... Keep the code pretty and easy to read and optimize/uglify the critical often-executed parts. Optimization takes place periodically during development. While optimizing you find out what part of the code takes most of the execution time and you cut it off here and there. Often these codepieces are found at the most unexpected places and the biggest performance degradations happen due to algorithmic problems.
|
|
|
|
|
Your analysis is a bit flawed.
First of all, you don't need to empty the string before populating it:
bkelly13 wrote:
<br />
void B( CString &some_string ); {<br />
some_string.empty(); some_string = internal_string;<br />
}<br/><br />
There are several things that happen in this (fixed) code that don't happen in the 'first call' version. When calling the API, there is more setup on the part of the caller. A CString variable needs to exist already, and API setup makes sure that it is either empty or ref count is zero (and writable). Assuming that internal_string is another CString, no copying takes place. The some_string object's header info is updated to duplicate the same info in internal_string, and the ref count is incremented. If internal_string is 1MB in size, only a pointer and counter are changed (ie. no copying).
Again, if internal_string is a CString, a similar process also happens in your 'first call' code (ie. no copying).
If internal_string is a (const?) char* or (const?) char[] or something else that looks like one of those, then a copy needs to take place for both versions of the code.
Windows 8 is the resurrected version of Microsoft Bob. The only thing missing is the Fisher-Price logo.
- Harvey
|
|
|
|
|
Option 2 can be preferred for object return.
Option 1 is usually used to return primitive types.
|
|
|
|