|
Will you PLEASE read the guidelines[^] and post messages that people can understand?
Why are you using an ini file to store the Window's title? What's wrong with using a string table? What exactly are you trying to achieve?
Karthika85 wrote: SetWindowText is not working.
And what does that mean? What does your code look like?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
First,i want to change the default title of a window. I can change the default title in String table.In future,If somebody wants to change the title of my application, again they have to change the string in resource,again they need to compile the whole application.So i want to configure the title in ini file.
I added SetWindowText function inside OnCreate function.Its not working.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
int *num,i,j=m_wndToolBar.GetToolBarCtrl().GetButtonCount();
num=new int[j+1];
memset(num,0,(j+1)*sizeof(int));
num[0]=j;
for(i=0;i<j;i++)
{
if(ID_SEPARATOR == m_wndToolBar.GetItemID( i ))
num[i+1]=1;
}
//·Ö¸ô·ûËãÊÇÒ»¸ö°´Å¥£¬¿í¶ÈÓÀԶΪ6
//ÉÏÃæµÃµ½µÄ°´Å¥¾ØÐÎÓÀÔ¶±È¹¤¾ßÀ¸±à¼Æ÷ÀïÃæÉ趨µÄ³¤¿í¸÷´ó7
//Èç¹ûΪ¹¤¾ßÀ¸ÉèÖÃÁËλͼ£¬°´Å¥µÄÐÎ×´ÓÀÔ¶Ö»Óë´´½¨Î»Í¼Áбíʱָ¶¨µÄ´óСһÖ£¬ÓëÆäËûµØ·½µÄÉèÖÃÎÞ¹Ø
m_wndToolBar.SetFullColorImage(IDB_BITMAP2, RGB(255, 0, 255), num);
delete []num;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
SetWindowText("Test");
return 0;
}
|
|
|
|
|
try this way
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
cs.lpszName = "Test";
<br />
return TRUE;<br />
}
maybe you need add following statement before the cs.lpszName = "Test";
cs.style &= ~FWS_ADDTOTITLE;
|
|
|
|
|
Thanks.I got it.
We should call SetWindowText inside OnInitialUpdate function.
void CToolbarView::OnInitialUpdate()
{
CView::OnInitialUpdate();
CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
pFrame->SetWindowText("title");
}
|
|
|
|
|
Hi,
im creating combobox ctrl Thru code but not from resource...and Pls let me know how can i increase the height of the ctrl based on the font...ie if the font is small ctrl should be small else if the Font is bigger Ctrl should increase....
i used SetFont() but it doesn"t help...
and even i tried using GetComboBoxInfo and obtained HWND hwndItem,HWND hwndList; handles for Editbox and drop-down list but i want to know how can i setfont for the same...
|
|
|
|
|
SetFont() will not automatically change the size of the combo box. You can use GetTextMetrics() to obtain size information about about the font, calculate the minimum size necessary to display the font in the control and then manually adjust the size and position of the combobox.
I am a lean mean ground beef machine!!!
|
|
|
|
|
I'm automating Word but some of the method calls I use can be lengthy (they show Word dialogs and the method doesn't return until the user closes the dialog from Word) during which time my GUI thread blocks, because the COM method call I've called doesn't return until the operation in Word is finished. This freezes my app's dialog.
I want to avoid blocking my main thread by making a COM call that returns immediately without waiting for results, like PostMessage vs SendMessage.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
as with most of these GUI main thread issues, it seems logical in this case to build a worker class to handle the COM interaction with Word in a seperate thread .. I dont quite see this :-
sashoalm wrote: COM call that returns immediately without waiting for results
happening as you've expressed it, but there's no reason why the worker/COM thread cant use some sort of event/messaging to let the gui know when its finished/done the Word tasks ...
'g'
|
|
|
|
|
COM's apartment model for threads causes problems with that, though I've been told that using CoInitializeEx(0, COINIT_MULTITHREADED); in both worker and main thread can solve it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Lengthly tasks are belonging in different threads!!! So write a thread which is calling the COM.
Your problem is screaming for threading
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I need my program sleep 1 microsecond, but Sleep() can not do this.
So, can I use select() instead Sleep() to do this?
<br />
timeout.tv_sec=0;<br />
timeout.tv_usec=1;<br />
FD_ZERO(&readfd);<br />
<br />
ret=select(0,&readfd,NULL,NULL,&timeout);<br />
It's have any problem or not?
|
|
|
|
|
Why sleep? There is also the WaitForMultipleObject()-API
"Carpe diem"
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
hanlei0000000009 wrote: I need my program sleep 1 microsecond, but Sleep() can not do this.
Neither can any other API do this (under Windows). Windows was never designed to provide this kind of functionality (it is not a real-time OS).
If you use something like Sleep(2) , your program may sleep for 2 milliseconds, may be 3, or 4, or say even 100 ms. There's no guarantee about this. The thread scheduler tries its levels best to put your thread to an 'unschedulable' state for as close as possible, to what you've asked. But, it can almost never be exact.
So, while Windows cannot even promise you the precision of milliseconds, you can forget microseconds, which is 1000 times the precision of milliseconds!
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Yeah, that's not happening...
Why 1 microsecond, FFS? What are you trying to do? BEcause there may well be a better way.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hanlei0000000009 wrote: I need my program sleep 1 microsecond...
If you need this delay in order for the code to work, you've got an underlying problem that needs to be resolved. Adding arbitrary delays such as this is just asking for trouble later.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
|
Actually, they won't help. The OP wants resolution in terms of microseconds!
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well it's going to be better than a standard timer, so it's at least closer
|
|
|
|
|
I was particularly avoiding in providing any possible solution to him, because the OP's approach has a fundamental flaw (introducing 'artificial' delays in his code). And to answer you, NO, multimedia timers are neither going to provide resolutions any closer to microseconds! Not under Windows.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: And to answer you, NO
I do not claim that they have a resolution of microseconds. But they have a resolution which is considerably higher than the standard timer so they come closer to the goal. Sure they don't reach it, but being closer is better than .. well.. not being closer
|
|
|
|
|
harold aptroot wrote: But they have a resolution which is considerably higher than the standard timer so they come closer to the goal. Sure they don't reach it, but being closer is better than .. well.. not being closer
Well, why don't you understand? Do I have to say again? It is NOT closer to the goal. The goal itself, is unachievable. Windows does not support such things. Not to mention the OP's approach is flawed.
For an OS to provide real-time functionality, it would require a very strong knowledge of the underlying hardware (including how fast each and every device is, how fast is the bus, the processor, how will they behave under specific conditions, etc.,). However, Windows was designed to support a wide variety of hardware, which means that the OS cannot practically have a deep knowledge of each and every hardware device that it may have to work with. So they had to compromise on this part.
Is that you down-voting? Why? Because I don't agree with your comment? Well, your comment is WRONG.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You think it is not closer. But it is. He's never going to reach the goal, but a better resolution takes him closer to his goal. Just because you can not get there doesn't mean you can not get closer.
And yes I gave you a 3, not because you disagree but because You are the one who is partically wrong. It would be closer to his goal.
It's like trying to reach 0K (zero Kelvin) really - you won't reach it, but you can get a lot closer than your kitchen freezer (which would be the normal timer in this analogy)
So why won't I understand? Because it isn't true in the first place.
edit: and here's an other one: suppose someone says "I want to get positive infinity using an integer! I am using uint32 now but it won't go high enough", well of course he can't reach it, but he could get closer using an uint64. It could be that he didn't really need infinity but just "something really high" and that it would help him anyway, just as in this case the OP may not know that multimedia timers exist and they may be good enough for what he's doing - who knows? At least he will be better off knowing that they exist.
|
|
|
|
|
harold aptroot wrote: At least he will be better off knowing that they exist.
Fine, he'll know that such a thing exists. That's the only point I can take. But, I won't take the "it's closer to the goal" codswallop.
harold aptroot wrote: And yes I gave you a 3, not because you disagree but because You are the one who is partically wrong. It would be closer to his goal.
Now, you're being ridiculous. How is it closer? He's trying to achieve something that would require an RTOS, but is doing that task on Windows. So, how is any approach going to be closer to the goal? Not only you don't know about the subject, but you're also down-voting because you think that I'm wrong.
How long have you been doing C++ or programming Windows to say that using a multimedia timer can be closer to make Windows behave like an RTOS? I'd assume that you're a teenager, have never worked on any professional project, and are talking about stuff that you know superficially (or know nothing about) here. I'm not wasting another minute on you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: I'm not wasting another minute on you.
Well thanks. But in my world any improvement means you're closer. And going from normal timers to multimedia timers is definitely an improvement if your goal is a very short wait. Thus it is closer. Are you getting extremely offensive over a definition of "closer"? Come on now.
Rajesh R Subramanian wrote: He's trying to achieve something that would require an RTOS
Yes, so it's impossible, but so what? You can still get a lot closer to the goal than a 18ms resolution.
Honestly now, an answer that is not right does not deserve a 5, a 4 is more fitting, you do have a point, however your definition of closer does not match the one in the dictionary.
This isn't even a programming matter, it's just you having odd definition of being closer to a goal.
Btw including my age in the argument is argumentum ad hominem - in other words, you would be wrong by default.
|
|
|
|
|
Thanks all.
It's looked like I need transplant my project From Windows to Linux or Unix.
timeval's member tv_usec is a value in microseconds. It declaration and used in UNIX first.
So, I think UNIX, FreeBSD for example can do this as possible.
|
|
|
|