|
This is strange to me. Let me get a few things straight:
1. Is the calendar control on the dialog bar itself? If not, where is it?
2. Have you overriden *ANY* painting/drawing methods at all. If so, which ones and what does your code look like?
3. How did you add your dialog bar to the project?
4. Is your application an MDI or SDI?
Let me know.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
perlmunger wrote:
1. Is the calendar control on the dialog bar itself? If not, where is it?
2. Have you overriden *ANY* painting/drawing methods at all. If so, which ones and what does your code look like?
3. How did you add your dialog bar to the project?
4. Is your application an MDI or SDI?
Thanks for your reply, Matt....
4. MDI.
1. The calendar control was created with the VC++6.0 dialog editor to be part of the Dialog.
2. I did override OnCreate in the DialogBar with the following. (Sorry, I couldn't get the tabs to copy over.)
int CDiagGlobalSched::OnCreate(LPCREATESTRUCT lpCreateStruct) <br />
{<br />
if (CDialogBar::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
<br />
int i;<br />
CRect CERectHome(245, 8, 260, 25);<br />
CRect CPRect(245, 54, 260, 96);<br />
CRect CERect;<br />
DWORD BaseStyle = WS_CHILD | WS_VISIBLE;<br />
DWORD EditStyle = BaseStyle | ES_CENTER | ES_NUMBER;<br />
for (i=0;i<21;i++) {<br />
CERect = CERectHome;<br />
m_CEDayOfWeek[i].Create(EditStyle | ES_READONLY | WS_EX_STATICEDGE,<br />
CERect, this, 2000+i);<br />
CERect.OffsetRect(0, 23);<br />
m_CEDate[i].Create(EditStyle | ES_READONLY | WS_EX_STATICEDGE,<br />
CERect, this, 2100+i);<br />
CERect.OffsetRect(0, 70);<br />
m_CEAllocated[i].Create(EditStyle | WS_TABSTOP, CERect, this, 2200+i);<br />
CERect.OffsetRect(0, 23);<br />
m_CEAvailable[i].Create(EditStyle | WS_TABSTOP, CERect, this, 2300+i);<br />
<br />
m_CPProgress[i].Create(BaseStyle | PBS_SMOOTH | PBS_VERTICAL,<br />
CPRect, this, 2400+i);<br />
<br />
CPRect.OffsetRect(20, 0);<br />
CERectHome.OffsetRect(20, 0);<br />
<br />
}<br />
<br />
<br />
return 0;<br />
}
3. I used the following command in my main frame's OnCreate() function:
...
if (!m_SchedDlgBar1.Create(this, IDD_GLOBAL_DLG,
CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
{
TRACE0("Failed to create Sched dialogbar\n");
return -1;
}
m_SchedDlgBar1.UpdateData(FALSE);
...
Any further suggestions you can give would be greatly appreciated. Thanks!
JennyP
|
|
|
|
|
Some things that are done by the framework behind the scenes aren't very clear to me, however, in general I don't mess with the mechanisms Microsoft has set up to make your application development quicker. That being said, sometimes you have to do things yourself.
I'm not sure that you're really helping yourself by creating the controls manually. I've never done it this way, so I'm no expert on it. When I need an index of my controls, I just create an array with all of their resource IDs in it and iterate through that with GetDlgItem. While this is probably not your problem, I do wonder if there is something about adding a control (CEdit in your case) with the create method to a DialogBar. DialogBars inherit from CControlBar (which inherits from CWnd) rather than CDialog. While adding to a CWnd is acceptable, it is normally a CDialog where this would be done. Again, this may have nothing to do with your problem. Just food for thought, I suppose.
What I usually do when I want to add a dialog bar to my application is I use the Project | Add to Project | Componenets and Controls menu in Visual Studio. In the ensuing dialog box, open the "Visual C++ Components" folder and select the "Dialog Bar" component. Click Insert and then OK on the Dialog Bar creation dialog. This will automatically insert a new resource into the dialog resources. Just open the resource and drag and drop your componenets as needed just as in a normal dialog. It will work as expected out of the box because it was implemented within the framework.
So, where does this leave you? To be honest, I'm not sure exactly. It kind of depends on you. I will send you a demo project I created that does just this and you can view the code there. However, the components added to the dialog are done through the resource editor and not manually.
If I were you, I would backtrack until you can get it to update/repaint properly. A control should rarely need you to update the drawing for it, so your UpdateData(FALSE) method should never need to be called. Just remove controls until you see it update properly and then add them back in testing to see if they work as you go.
Best of luck to you and I hope that this had been helpful. Maybe someone who knows more about creating the controls manually could be more help to you. Let me know if you have other questions. I'd be glad to help you muddle through it any way I can .
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi Matt,
With your help, I was able to solve the issue. It turns out that my VC++ wizard put in "AFX_IDW_DIALOGBAR" to both of my dialog bars' nID fields (in the Create() method). I used your suggestion to roll my own nID's (in resource.h) and it worked.
In addition, I was able to remove UpdateData() from MainFrm.cpp which was really a cludge because my first dialog bar kept crashing the program if I didn't click on the document before the dialog bar. This was probably because the dialog bar wasn't properly initialized as in the first paragraph.
If you could offer some ideas of why VC++ put in AFX_IDW_DIALOGBAR instead of a new one, I'd appreciate it... Is this something I should do for all such items? Also, if I update resource.h manually, will the VC++ wizard try to use the same integer if I create a new resource later?
Finally, I'm manually creating (with no help from the dialog wizard) some edit controls because I'm wanting to draw them in a grid pattern on the dialog bar, and the dialog wizard just doesn't seem to get them exactly spaced equally (even using its space-even command).
Thanks for your help!
JennyP
|
|
|
|
|
>> If you could offer some ideas of why VC++ put in
>> AFX_IDW_DIALOGBAR instead of a new one, I'd appreciate it...
>> Is this something I should do for all such items? Also, if I
>> update resource.h manually, will the VC++ wizard try to use
>> the same integer if I create a new resource later?
This sounds like an anomaly to me. I've never had this problem before, but then again, I've never had two DialogBars in an app. I guess the best advice is to learn from the symptom so that you can quickly diagnose the problem next time.
Also, I've edited both resource.h and the .rc file manually before and found that, if you're careful, you can do this without causing any problems. I am almost completely certain that as long as you don't introduce duplicate items to resource.h yourself, whether by ID or name (which should be caught by the compiler), you should be fine. I believe VC++ re-parses the file to determine the next ID every time a new resource is added.
I'm glad you've solved your immediate problem, though. Best of luck to you and best regards. If you have any other questions, let me know.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I use IHTMLDOMNode::put_nodeValue in a Browser Helper Object, but it crashes when I open a second instance of the browser. Someone already experienced this ?
|
|
|
|
|
virtual Key not affect
I try this in KeyDown function :
if (nChar == VK_RETURN) MessageBox("Test","Test",MB_OK);
but VK_RETURN not affect
please help me. thanks
|
|
|
|
|
More source code post you must. Dialog window your window is?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
maybe try your code in OnChar()?
|
|
|
|
|
You need to provide more information.
In what function are you testing nChar (OnKeyDown, OnChar etc.). Also, if you are using a dialog window you should filter messages in PreTranslateMessage.
Best regards,
Alexandru Savescu
|
|
|
|
|
(Maybe you chaps know better than the MC++ chaps)
Ok so I have a MC++ Class Library and it is being called from a C# app. All hunky dory, except I cannot get the class library to write to any files when it is called from the C# app.
I wrote the equivalent code in the C# app and the file was created fine and in the right place.
Am I supposed to be doing something extra to tell the system that the class dll can write files?
The crappy thing is that no error is generated, in fact stepping through each line the system seems to think the file was created just fine. But no file appears.
I am using the XMLTextWriter to write the file. e.g. myXmlTextWriter = new XmlTextWriter (S"test.xml", System::Text::Encoding::UTF8);
I have used Flush and Close, no luck.
So what gives? thanks.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Paul Watson wrote:
But no file appears.
Try with absolute path name. The file is generated but you are looking at the wrong place.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Rama Krishna wrote:
Try with absolute path name. The file is generated but you are looking at the wrong place
I wish Rama. That was my first thought, so I tried c:\test.xml to no avail. I even checked in the DEBUG folder, then set the project to RELEASE and checked in that folder. Nix, nada, nothing. Even compiled the app and ran it out of the DEBUG environment. Nothing.
I even put in a FUBAR path (e.g. c:\sibling\kill\die!.][\\wicky\test.xml) and it still ran without generating an error. I would think it would throw an exception with a path like that.
Some further info: The app that runs is the c# app. It loads with a Windows Form and in the form_load it creates an instance of the class I coded in C++. It then calls a function in that class which contains the code which is supposed to write an XML file.
If I take that XML code, translate it to c# and put it in the c# app, then the XML file appears.
If I run the C++ class library on it's own and call that function, the XML file appears.
But as soon as I try and call the c++ class lib function from c#, the XML file does not appear. No errors either.
To me it seems as though the c++ class lib is not getting the neccesary rights to write a file. But then it should throw an exception surely?
*sigh* Be glad when this contest is over lol
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Maybe you forget an extra \. You should do: C:\\file.txt . Just guessing
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexpro wrote:
Maybe you forget an extra \. You should do: C:\\file.txt. Just guessing
Good idea, but alas, no luck.
Further info: I just moved the code out of the one function and into a function I know was working earlier. Lo and behold it starts returning exceptions. Errors I can deal with, it is when you get nothing that I get frustrated.
Maybe I should try this in normal C++ and leave MC++ alone.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Paul Watson wrote:
Maybe I should try this in normal C++ and leave MC++ alone.
Or return back to familiar terrotories.
C++ doesnot work for some people. It looks at the personality first and decides whether it should work for the person or not.;)
If possible mail me the code. This looks very weird problem.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Rama Krishna wrote:
Or return back to familiar terrotories.
C++ does not work for some people. It looks at the personality first and decides whether it should work for the person or not
Wave a read flag in front of my face why don't you!
That is tantamount to a challenge of the highest order. Now not only do I have to win that contest, but I have to do it well enough to impress Rama Programmer Guru Krishna, hehe.
Well I don't fully understand the problem yet, but I have got the code working by not using a bool and rather using a String* . I assume it has some managed types explanation behind it.
You can check it out when I submit my article
Thanks for the help.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Is it possible to assign a thread to a single processor in C++ with Visual studio ?
|
|
|
|
|
Check SetThreadAffinityMask. But better be sure what you're doing.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
If you are simply concerned that windows is optimizing your threads processing effectively, you should know that it runs all of your threads on different processors until it has to double up on a processor. So it tries to maximize the through put of the multi-processors parallel processing.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
In MFC, how would you go about getting that PATH of the current executable - AfxGetAppName is not enough.
Help
|
|
|
|
|
__argv[0] should do the trick. It's global variable in MFC.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
__argv[0] will contain incomplete path when you launch the program from command line. Seems that most reliable way of getting the path will be ::GetModuleFileName.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Cheers. I had a feeling about GetModuleFileName, but thought it would only provide the filename again.
|
|
|
|
|
Giles wrote:
I had a feeling about GetModuleFileName, but thought it would only provide the filename again.
It'll give you complete path, including filename. If you want to have only directory part left, copy the filename into CString, then use CString::ReverseFind and CString::Left.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|