Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Reading a comma delimited file to arraymemberDavidCrow14 Feb '13 - 5:14 
Jeffrey Webster wrote:
At this point I'm trying to get a really granular understanding of C which even means reinventing the wheel at times, just for my own edificationSmile | :)
A good strategy. Thumbs Up | :thumbsup:

"One man's wage rise is another man's price increase." - Harold Wilson

"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

"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous


QuestionImplementing of Interruptionmembermohammad torabi13 Feb '13 - 10:14 
Assume that there are 8 Modules which one of them is Supervisor. They are implemented in C++ classes, so we have 1 Object of Supervisor and more than one Object of other module.
 
The Supervisor assign Tasks to each other module, and whenever they finished their tasks or faced with a problem, they should inform the Supervisor.
 
I think that the best way to implement this behavior is Interruption or something like that.
 
Now, I want to know how to implement it or is there any solution for this problem?
AnswerRe: Implementing of InterruptionmemberAlbert Holguin13 Feb '13 - 11:49 
Messaging[^] suits this well and is the native Windows way of handling such tasks... but I'm sure there are many options.
AnswerRe: Implementing of InterruptionmemberStefan_Lang15 Feb '13 - 3:39 
Using interrupts is something you do when your program needs to interact with hardware components that trigger these interrupts. Software can trigger only one type of interrupt, and that is by setting a timer. Your problem is not timed, it is controlled by demand, so setting a timer does not fit that problem. using a timer in this situation is like telling a home owner that instead of reacting to the door bell, he should rather check the door every 5 minutes.
 
I suggest you fire up your preferred search engine and search for the keywords "master slave pattern". This should provide you with lots of interesting links.
 
The master slave pattern is extensively used for organizing the parallelization of complex tasks. Each slave works (potentially) on its own thread, allowing it to work in parallel with its coworkers. That means telling a slave to work requires sending a message to a different thread or process. Since inter-process communication is rather slow, you should prefer the former.
 
In most cases it is not necessary for the slaves to live beyond the scope of their tasks. Therefore, the easiest way is to create a new thread for each slave, whenever you need one. The problem you describe assumes a fixed number of slaves however, implying that these slaves' livetimes are not linked to the tasks they work on.
 
In that case you need a messaging system that allows the supervisor to inform the slaves if and when they are needed, and the slaves to inform the master after they're done. The windows messaging system - as suggested above - should work well for that purpose.
 
The disadvantage of messages is that the master needs to keep track which of his slaves are busy. Also he'll need to queue the tasks if all slaves are busy, until one becomes available.
 
Since you need the ability to queue your tasks anyway, a better solution would be to just push your tasks there, always, and let your slaves pick up work items from there whenever they're idle. That way the master doesn't need to know if or who is available for work. He wouldn't even need to be informed every time a slave is done with his work item; instead, the queue could notify him when it is empty, i. e. the entire workload completed.
 
The only reason not to do that would be if your slaves are specialized to different tasks, but not able to decide for themselves which these are. (e. g. this may happen when the data associated with the tasks come in different formats that the slaves cannot interpret)
AnswerRe: Implementing of InterruptionmemberMax_Power_Up26 Feb '13 - 5:33 
Hi, you need too Google the "Observer Pattern" to see a very well explained answer to your question. Hope this helps.
For awesome websites or just to chat check out my blog for more info. . .

QuestionLine number Add-inmemberKrishnakumartg13 Feb '13 - 5:20 
Hi,
 
I have an idea to develop one MSDEV (VC6) addin that shows the line numbers in editor (like the VS2008 IDE).
 
Could you please give me the basic idea that I should follow (i mean how to modify the existing editor window)?
Krishnakumar TG

QuestionRe: Line number Add-inmemberMaximilien13 Feb '13 - 8:14 
Krishnakumartg wrote:
I have an idea to develop one MSDEV (VC6) addin

 
Why, oh, why do you want to do an add-in for an antiquated IDE ?
 
Confused | :confused:
Nihil obstat

SuggestionRe: Line number Add-inmemberAlbert Holguin13 Feb '13 - 8:59 
I agree with the previous post... why would you want to develop something new for something so old? D'Oh! | :doh:
 
If you just want a project, I'm sure you can find other more useful and productive things to work on. Line numbers are hardly ever useful either, I've never had the need for them (I guess if you're having a need to discuss a file with another coder they'd be useful but I've never needed them).
AnswerRe: Line number Add-inmemberjschell13 Feb '13 - 10:12 
Krishnakumartg wrote:
Could you please give me the basic idea that I should follow (i mean how to
modify the existing editor window)?

 
Have you already researched whether that VS supported Addins at all?
 
If it does then finding examples would be one way to approach it.
QuestionCombine two windowsmemberKrishnakumartg13 Feb '13 - 5:16 
Hi,
 
I am trying to prepare a test application that combines two windows. I visualize that if one window is dragged, the other one also drags automatically.
 
For this,
1. I created a dialog based app
2. In button click created a new window (other than dialog apps window). And the new window is attached with the dialog apps window.
 
But after the button click whole the app hangs. Unable to touch the windows.
 
The code is as follows. Could you please help?
 
CWnd NewWindow;
void CAttachDlg::OnButton1() 
{
	CRect crect( 0, 0, 500, 500 );
	RECT rect;
	rect.left = 0;
	rect.top = 0;
	rect.right = 100;
	rect.bottom = 100;
	CString csClassName = AfxRegisterWndClass( 0 );
	
	BOOL bReturn = NewWindow.Create( csClassName, "Test", WS_POPUP | WS_VISIBLE, crect, this, 0 );
	RECT wRECT;
	GetWindowRect( &wRECT );
	wRECT.right = wRECT.left - 1;
	wRECT.left = wRECT.left - 100;
 
	NewWindow.MoveWindow( &wRECT, TRUE );
	this->Attach( NewWindow.operator HWND());
}
Krishnakumar TG

AnswerRe: Combine two windowsmemberprabhjot.cgc13 Feb '13 - 17:29 
Hello Krishnakumartg,
 
Use CreateEx method insted of Create. Because WS_POPUP cannot be used with the Create method.
QuestioncmemberMember 983250613 Feb '13 - 2:39 
How to shut down computer using c programming?
AnswerRe: cmemberOrjan Westin13 Feb '13 - 2:49 
By calling the appropriate OS API, if any, if you are permitted.
AnswerRe: cmemberMatthew Faithfull13 Feb '13 - 2:51 
Basically two ways to do this that I know of:
 
1. Make a call from your C code to the Operating System API for shutdown. Which API call, what permissions you need and what options you have depends on the Operating System.
 
2. Break out the books and learn to make ACPI BIOS calls, probably more assembler than C. This will do it fast and sure but you may corrupt your OS and will certianly loose any unsaved data if you go this way.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)

AnswerRe: cmvpRichard MacCutchan13 Feb '13 - 3:22 
See http://msdn.microsoft.com/en-us/library/windows/desktop/aa376876(v=vs.85).aspx[^].
QuestionRibbon To existing MFC Applicationmemberyogeshs12 Feb '13 - 19:53 
Hello Friends
I am going to add Ribbon Toolbar in My Existing MFC application. As i go through on net,i found that in VS2010,we can create Ribbon Resource using Ribbon Designer Inspite of using Ribbon Classes to create Ribbon Toolbar.
 
Now, I am using VS2010. I want to know How can I Add Ribbon toolbar to my application which is using old toolbars. Do I need to create Ribbon Resource Independently and then to load in Exisitng Application Or Some other Way to DO it?
Any Help Will be Appreciated.I want to in Right way when I update to Ribbon toolbar.
 
Thanks In Advance.
Regards
Y
AnswerRe: Ribbon To existing MFC ApplicationmvpRichard MacCutchan12 Feb '13 - 22:17 
Take a look at some of these articles[^].
QuestionCAsyncSocket exceptionmemberForNow12 Feb '13 - 19:47 
Hi,
 
I have a derived CAsyncSoct class as a member of a Derived CwinThread Class
the members that I have in my derived CAsynSocket class include data members such as a port no
that I wish to connect to
 
so...
 
class CSocketThread : public CwinThread
{
public
CSocket thisicket
 
}
 
class CSocket : public CAsynSocket
{
 

I create a UI thread
 
via new SockThread(start_port)
 
I create the thread suspended
 
fill in the missing pieces such the ipaddr, port #
 
Then do a resumethread this should kick the SockThread:Iinitinstance overridable
 
I figure by this time everthing the SockThread and Csocket Objects has been Created
 
So in the SOckThread::initinstance I do a Socket.create withe yhe ipaddr and port
 
By the time i get to create the third of fourth thread I get an exceptin from
 
CAsynSocket::Create
 
One of my questons is if I create the SockThread on the heap via new does that mean
every data memeber and or classes such the CSocket is contructed on the heap
 
and is there something wrong with my design
 
Thanks in advance
AnswerRe: CAsyncSocket exceptionmemberOrjan Westin12 Feb '13 - 23:04 
First of all, without synchronisation objects, you can't rely on anything having happened in another thread.
 
Second, CAsynchSocket has some inherent design problems (see CSocket considered harmful). You might want to consider rolling your own using the Win32 SDK if you're going to keep it running in a separate thread.
 
Third, you shouldn't create your CWinThread object directly. Use AfxBeginThread instead.
GeneralRe: CAsyncSocket exceptionmemberForNow13 Feb '13 - 6:10 
Thank you for response youe point about synchronistion is well taken
 
Second I am creating a UI thread as I want the send/receive socket to be initiate dvia messages and I dont beleive the owrker threads can process messages
 
I didn't know there were porblems with CSocket
 

Thank you
Questiondisabele right click popup menu in win32 browser controlmembervenkatesh5286712 Feb '13 - 19:30 
i used browser control in win32 dialogbox. i want to disable rightclick popup. who can i do that .
AnswerRe: disabele right click popup menu in win32 browser controlgroup_AnsHUMAN_ 13 Feb '13 - 2:35 
Is it your application wherein you are going to do this, or do you want this to be across the SYSTEM?
You talk about Being HUMAN. I have it in my name
AnsHUMAN

GeneralRe: disabele right click popup menu in win32 browser controlmembervenkatesh5286713 Feb '13 - 3:41 
yes,i have one win32 diallogbox with one browser custum control. i am calling this dialog from dll.it is working fine.i taring to disable right click of web browser control.
AnswerRe: disabele right click popup menu in win32 browser controlmemberStephen Hewitt13 Feb '13 - 21:49 
Try the IDocHostUIHandler::ShowContextMenu[^] method.
 
Steve

QuestionHow to retain row color while highlighting in Clist controlmemberHareeshaK12 Feb '13 - 16:33 
Hi,
 
How can i retain the text color while highlighting a particular row in Clist control
 
I am using a derived Clist control where already draw item is overridden in the name of OnNMCustomdraw (OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult))

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid