|
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
|
|
|
|
|
are you talking about english, french, spanish language ? or C, C++, ... language ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
this question is not a VC++ question but i put it here because VC++ developers are the best.
I want to write software that uses computers on a LAN to and use there processor resourses, synchronize them, to gain a huge processing power, I may use tens to hundreds of workstations on the LAN.
Another point about sharing resourses:
when I want to share processor resourses, can I have special hooks on the system such that when I run a program( say 3dmax), the processing load will distribute on the network nodes? Can this be done???
by the way: I heared that a company created a screen saver that is used to share processing resourses (when the leaf computer is idle), all nodes are controlled by the company's computer. How could they run there own code (that did not ship with the screen server) on leaf computers???
any ideas are welcome?
Thanx All,
Mohammad Gdeisat
|
|
|
|
|
|
See Beowulf [^]
Good luck, this is a challenging topic.
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Did you have a look at the GRID and GRID middleware software?
|
|
|
|
|