|
|
Good day,
I'm reposting my problem since i havent got an answer. I have a two dialog(main, child), the main is the normal dialog when you start to create a dialog application in EVC. The child dialog is a modeless dialog here is how the child is called.
CMyChild* childform=new CMyChild(this);
childform->Create(CMyChild::IDD);
childform->ShowWindow(SW_SHOW);
The child also has a public function UpdateProgress bar which updates the progress bar of child dialog. I have also a function in child dialog which updates the text much the same as updating the progress bar. here is how it is called.
CMainDlg::MyMainFunc()
{
CMyChild* childform=new CMyChild(this);
childform->Create(CMyChild::IDD);
childform->ShowWindow(SW_SHOW);
childform->UpdateProgress(10); //updates the progress bar by 10 steps..
childform->UpdateProgressStatusText("Loading 10%"); // updates the static text But doesnt work..
childform->UpdateProgress(210); //updates the progress bar by 10 steps..
childform->UpdateProgressStatusText("Loading 20%"); // updates the static text But doesnt work..
}
I'm sure that I change IDC_STATIC to IDC_LOADINGTEXT so id will not be the issue. My problem is why is that progress bar is updated with what i pass but UpdateProgressStatus is not updated with the text that I pass?
Here is the two child functionss.
void CMyChild::UpdateProgress(int pStep)
{
m_ctrlProgress.SetPos(pStep);
}
void CMyChild::UpdateProgressStatusText(char* text)
{
CString tmp;
tmp=text;
GetDlgItem(IDC_LOADINGTEXT)->SetWindowText(tmp);
}
Im sure that i set the property of IDC_LOADINGTEXT to visible. Still why is that the modeless dialog is not updated with the text I pass and the progress bar is updated.??
Pls. Help.
Thanks.
|
|
|
|
|
hi,
I am not an expert but i have experinced through your knid of problem.
here when you create the dialog box, you see there is an option redraw in its properties. Try executing it after changing the redraw property to no redraw.
If then also it doesn't work, following is the solution (This is what i used).
what i did was i created the modeless dialog box in the main thread and started a new thread. this new thread will do the work i wanted and then it calls the incrementprogress function of the dialog box class. Now the problem here is in the thread the dilog object wont be visible. to do this
1. easiest, you can delare the dialog object golbal.
2. recomended, you pass the object reference(this pointer) to the thread parameters.
Tell me if it works, an ya don't forget to rate it.
|
|
|
|
|
Hello,
I found another way to solve my problem though it may be not a solution to CStatic problem but this can be a work-around of displaying a progress text status. Though i have solve my own problem still I want to share info so that if someone encounter this problem, He/She may try our solutions (By No Redraw Sol., or By Thread Sol , or By Drawing Text Solution.).. Here is how I display the status to the child modeless dialog.
void child::UpdateStatusMessage(char* pmessage)
{
CString strmsg;
strmsg=pmessage;
CDC* cDC=GetDC();
CFont HeaderTitle;
RECT r;
HeaderTitle.CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,0,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,
_T("Arial"));
r.top=120; r.bottom=140;
r.left=30; r.right=100;
cDC->SelectObject(HeaderTitle);
cDC->DrawText(strmsg,&r,DT_NOCLIP);
ReleaseDC(cDC);
}
Thanks.
|
|
|
|
|
hey buddy you need not do all this.
just Change the ID of the static message from IDC_STATIC to anything else (IDC_TEXT).
now go to class wizard and add a CString variable (msg) for IDC_TEXT.
now when ever you want to update it just say
<code>UpdateData(true);
msg="new messgae"
UpdateData(false);</code>
Tell me if it works, yaa don't forget to rate it.
|
|
|
|
|
well if u don't know much threading then you are same as i was a month back.
For threading search codeproject articles ( i don't have collection of it to tell you).
any way i will paste my code here if you can make sense out of it.
DlgProgress *dlglocprog;
DWORD WINAPI PseudoThreadFunction( IN LPVOID vThreadParm )
{
CMainFrame* pThreadParam = ( CMainFrame* ) vThreadParm;
pThreadParam->FunctionClients();
return 1;
}
bool CMainFrame::ExecuteLocateThread(void)
{
HANDLE hThread = NULL;
DWORD dwThreadID = 0;
int nTimeout = 5000;
try
{
hThread = CreateThread( NULL,
0,
PseudoThreadFunction,
this,
0,
&dwThreadID );
}
catch( CException* )
{
return false;
}
bool bFinished = false;
do
{
DWORD dwWaitResult = MsgWaitForMultipleObjects(
1,
& hThread,
FALSE,
nTimeout,
QS_ALLEVENTS | QS_SENDMESSAGE);
switch ( dwWaitResult )
{
case WAIT_OBJECT_0 :
case WAIT_ABANDONED_0 :
{
bFinished = true;
break;
}
case WAIT_OBJECT_0 + 1 :
{
MSG msg;
while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) == TRUE )
if ( !AfxGetApp( )->PumpMessage( ) )
{
::PostQuitMessage( 0 );
}
break;
}
default :
{
bFinished = true;
}
}
} while ( ! bFinished );
return true;
}
void CMainFrame::FunctionClients(void)
{
for(unsigned short addr=1;addr<256;addr++)
{
vi_Progress=addr;
dlglocprog->IncrementProgress();
Sleep(10);
}
dlglocprog->EndDialog(0);
b_LocateProgress=false;
}
void CMainFrame::OnClientoptionsLocateallactiveclients()
{
if(!b_LocateProgress)
{
b_LocateProgress=true;
dlglocprog = new CLocateProgress();
dlglocprog->Create(IDD_LOCATING_CLIENTS);
dlglocprog->ShowWindow(SW_SHOW);
dlglocprog->CenterWindow(this);
p_LogView->DisplayData("");
p_LogView->DisplayData("Locating all active clients...");
ExecuteLocateThread();
}
}
void ProgressDlg::IncrementProgress(void)
{
c_Progress.SetPos(vi_Progress);
UpdateData();
m_ProgressCount=c_Progress.GetPos();
UpdateData(false);
}
Tell me if it worked, an yaa don't forget to rate it.
|
|
|
|
|
i wnat to create a file to store a list of ids and name.
the logic should be such that when i give id it should return name.
so what kind of storage format i should go for to make my retrival easy.
|
|
|
|
|
Unless you are not willing to use any fancy database approach and run some queries,
you could go for an ASCII file, in which each line could contain text like:
22-Name
where the id is followed by a "-" and the name itself.
Then you use a CStdioFile object to read the file line by line.
Assuming now that you get the line info into some
char chText[256] variable, you go then for something like this:
<br />
char chName[256];<br />
unsigned int ID;<br />
sscanf(chText, "%u-%s", &ID, chName);<br />
As soon you get the ID value you are looking for, you stop the process of reading the file, close the file and return chName
I'm pretty sure, some other ways exist as well )
SkyWalker
|
|
|
|
|
|
I use the tecnique show in this article this is working fine in vc++ of visual studio 6, but in vc++ of visual studio the file is not stored properly.
How should i serialize and store my data
i want this to be done for a class derived from CDialog class.
Thanks for your time.
|
|
|
|
|
oh god i am really sorry,
I found the error.
When i inserted the serialization using the class wizard it inserted the code as follows
if (ar.IsStoring())
{
ar >> m_strName;
ar >> m_nIndex;
}
else
{
ar << m_strName;
ar << m_nIndex;
}
note IsStoring there.
and in the article the same function is as follows
<code>
if (ar.IsLoading())
{
ar >> m_strName;
ar >> m_nIndex;
}
else
{
ar << m_strName;
ar << m_nIndex;
}
</code>
note IsLoading here.
My mistake was i used the wrong indirection. Make a note of it and never do such a stupid mistake. I wasted 5 hours on this.
|
|
|
|
|
karmendra_js wrote:
I wasted 5 hours on this.
It was only a waste if you failed to learn anything from the experience.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
i have written a project in VC++ that creates reports for my compnay. but this application only allows one page. how do i code it, so that it support any no. of pages we want.
nams
|
|
|
|
|
In the print structure, set the number of pages to 2 or more.
The print page loop will run for each page#.
BOOL MyView::OnPreparePrinting(CPrintInfo* pInfo)<br />
{ <br />
int nPages = CalculateRequiredPages();<br />
pInfo->SetMaxPage(nPages);<br />
<br />
<br />
BOOL bRet = DoPreparePrinting(pInfo);<br />
pInfo->m_nNumPreviewPages = 1;<br />
<br />
return bRet;<br />
}
No see-you, no heal-you. Ptthh.;P - Der Dokter
|
|
|
|
|
Thx for the above code, but i guess this code is to print multiple pages. i needed help for supporting more than one page. whenever i enter data on the first page and if the amount of data exceeds the length of the page, the remaining data shld go on the next page. but that does not happen. i cannot put anything beyond that one page. so i want to know how does a new page get attahced automatically
also could u help with the code for print preview & print setup as i am new to VC++ i dont know much of its coding
Namrata
|
|
|
|
|
Hello,
I have a project that allows the user to search for files. While the search is being performed, I would like to display the animated search icon (a magnifying glass circling a folder). I have no idea how to do this or where to begin looking.
Any ideas?
Thanks!
-Ian
|
|
|
|
|
hello
usualy this is done not with a ico but with a avi movie
|
|
|
|
|
|
Ian Bowler wrote:
Any ideas?
Have you looked in your C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos folder?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
I am using ClistCtrl class.
It can scroll only up to the last item in the list. I need the functionality of scrolling further, let say, one more blank page, without any items.
How to achieve it ? Scrolling is done internally in the CListCtrl, and they also update the scrolling MaxPos, when the item is added, as far as I can tell.
How can I change that functionality ? Is it possible at all ?
Thanks
|
|
|
|
|
Probably you could derive your own class from CListCtrl and write your code for the
CMyListCtrl::OnHScroll() and CMyListCtrl::OnVScroll() handlers.
... why would you actually want to do that anyway ? ...
SkyWalker
|
|
|
|
|
SkyWalker, thanks for the reply
Ok, here is the deal:
ListCtrl should mimic the look and feel of the Microsoft Access table. I don't know if you're familiar with that application, but in short:
When a user filled full page with items, and he wants to enter one more item, he can scroll the whole window down, so that the first item is at the top of the window again. In CListCtrl, as it is now, you will always add items in the end of the list, or you can put extra blank items. But is not user-friendly
Now, I overrode CListView::DrawItem function, and drawing things myself. I ovverode VScroll as well, and in my VScroll handler, I can use CWnd:ScrollWindow function to scroll myself, and then DrawItem will be called by the system, to repaint only what is needed. It actually works, I checked it.
The problem is that internally, CListCtrl does not know about my changes. So, for instance, you would call ClistCtrl::InsertItem function to add an entry. CListCtrl will set rectangle coordinates for this item according to his own view of things. Or, if you want to delete an item.
And what a nightmare, if you want to sort items !
So, ClistCtrl calculates internally positions of entries, as far as I can figure out.
Of course, I could do myself all these operations, but this is like rewriting major portion of the CListCtrl class.
I want something kind of short, if possible. And this change would make deletion, insertion, and sorting work correctly.
I hope, I explained kind of clear what I've been trying to acheive
-- modified at 5:34 Tuesday 11th October, 2005
|
|
|
|
|
I'm working on a poker odds calculator. There are several for sale, but mine will only be used for personal use. It will have som functions that the others don't got.
But to the point, at the moment the cards are read when you push buttons for each one of them. I would like to make this as automatic as possible. I've never created a program that is connected to another yet, so I don't know much about this.
Many other calculators get information from the small chat window in the poker software. You can se the community cards, raises etc. How should I do to connect to the chat, and make my program to read in constantly?
And alternative nr 2, which makes it possible to read all cards, is to look at the graphics. I assume that you have to find some pixels that are unique for every card and so on, but how should I get started?
C++ Builder.
|
|
|
|
|
How does an application identify different languages supported by a single resource at runtime ?
Jim456
|
|
|
|
|