|
Update
Restarted browser and all my hard work dissipeared.
I will keep trying to fix this problem.
Desmond Mardle
|
|
|
|
|
Hi Friends,
I am new to code project, so I want to say a hello to all of you. and I am also new to programming. So I have a problem for you.
Can anybody please write a C++ code for solving Travelling Salesman Problem using dynamic programming algorithm?
Thanking You.
|
|
|
|
|
Hi, welcome in the C++/MFC forum. As you're new, I strogly suggest reading carefully the messagge at the top of the forum [^] before posting any question (for instance, "please send me code that solve my problem" should be avoided here).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I think you are not aware of this forum much, I sincerely suggest you to google for any code (if available) that you needed. And once you tried that and tired , then asking for help to solve that issue will help you.
- ns ami -
|
|
|
|
|
Runish Kumar wrote: Can anybody please write a C++ code for solving Travelling Salesman Problem using dynamic programming algorithm?
Yes, I'm sure somebody can.
"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
|
|
|
|
|
Runish Kumar wrote: I have a problem for you
Here's a starter[^] for you...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Hi Experts
I am accessing the database using VC++ and want to read a row at a time. Is there any API to read a row?
Thanks in advance
RYK
|
|
|
|
|
Usually recordsets do exactly what you want (you know: vague question => vague answer).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am using RDLC and i want to add dynamic text in header as well as in footer and some images in to the header but i cant understand how to add it in same rdlc.
i can add static text in header as well as footer and when i add dynamic text in header it will be displayed in the first page only(after saving report in PDF format) but i cant get same text in next continuing pages
will you help me please as early as possible
|
|
|
|
|
Hello,
I want to serialize structure like this:
struct FRAME{
int Len;// size of Text following
char Text[];
} ;
the problem is that this is not a fixed length variable! how could I read the structures after being serialized?
Thanks
|
|
|
|
|
Read 4 bytes first to get the length value.
Now read the number of bytes identified by length.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
The way it's usually done is something like this:
- Read
Len from whatever you're reading from - Allocate a buffer of size
Len + sizeof Len bytes. - Copy
Len into the first sizeof Len bytes of the buffer - Read
Len bytes into the buffer after the copied value of Len - Cast the buffer pointer to FRAME* and return it
Let's presume you're reading from a C FILE :
FRAME* ReadFRAME(FILE* file)
{
int Len;
fread((void*)&Len, sizeof(Len), 1, file);
char* space = (char*)malloc(Len + sizeof(Len));
FRAME* gotFrame = (FRAME*)space;
gotFrame->Len = Len;
fread((void*)gotFrame->Text, 1, Len, file);
return gotFrame;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Is there any new version of NtDsAPI.lib available for 64 bit application? If anybody knows plz reply.
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
|
I'm working on an application which uses a GDI+ bitmap and graphics object to double-buffer to the CView class (I don't use any Windows controls at all). This is all working very well, and I've certainly found GDI+ a little easier to work with than my previous experience working with GDI.
However, there are times when I need to be able to sustain refresh rates of around 50Hz on certain small portions of the screen. The drawing to the background bitmap isn't a big problem here, but the call to DrawImage() in OnPaint() is as it's taking a long time and chewing up a lot of processor time.
I've tried doing a GDI BitBlt() instead but while that function is fast, the creation of the HDC and HBITMAP and everything else needed isn't, and there's no speed advantage.
Has anybody got anybody got any ideas on how to speed up these calls to DrawImage()? I just don't believe that it should take up so much processor time to do so little - I know the GDI+ calls don't use hardware acceleration, but still...
|
|
|
|
|
Another idea:
Use two temp memory image(first is display,second is create in memory; change them when second is ready).
|
|
|
|
|
Thanks. Maybe I don't understand you right, but I'm not sure how that'd help. My bottleneck is the DrawImage() between the memory bitmap and the screen so wouldn't I have the same problem?
|
|
|
|
|
You dont need to create the objects every draw process. Create them at startup.
Try to draw the only changed parts of the picture or work with regions. ->CRegion
Or try subbitmaps.
Greetings from Germany
|
|
|
|
|
I'm creating the offscreen Bitmap and Graphics objects at startup, and I'm only updating a specific rectangle each screen update. It's just that the call to DrawImage() in OnPaint() takes a long time.
For example, to copy a 150x200 pixel rectangle from the memory bitmap to the screen takes 2 to 3ms on my machine, which at 50Hz screen updating hogs a lot of processor time.
What do you mean by subbitmaps?
|
|
|
|
|
substitute the DrawImage call. Make a offscreen HBM and use the faster bitblt.
Greetings from Germany
|
|
|
|
|
Redeye92 wrote: I've tried doing a GDI BitBlt() instead but while that function is fast, the creation of the HDC and HBITMAP and everything else needed isn't, and there's no speed advantage.
But I think you dont need to do it always. Once you copied to a memory dc, then only need to use BitBlt instead of each DrawImage.
- ns ami -
|
|
|
|
|
You know I was hoping that was going to be possible, but it seems that you can't write to the Graphics object whilst you've got its HDC. The code I've been using to substitute DrawImage() in OnPaint() is :
m_pbmpMemory->GetHBITMAP(Color::White, &m_hMemBitmap);
m_hMemHDC = m_gr->GetHDC();
SelectObject(m_hMemHDC, m_hMemBitmap);
BitBlt(pDC->m_hDC, rcPaint.left, rcPaint.top, rcPaint.Width(), rcPaint.Height(),
m_hMemHDC, rcPaint.left, rcPaint.top, SRCCOPY);
m_gr->ReleaseHDC(m_hMemHDC);
Am I missing something here which would save me having to do all the stuff around the BitBlt? I just can't see how to keep a hold of the HDC and HBITMAP between calls to OnPaint(), but I'd be a happy man if someone knows how to get around this.
|
|
|
|
|
Redeye92 wrote: I just can't see how to keep a hold of the HDC and HBITMAP between calls to OnPaint(),
You can create a memory dc and keep it permanantly (unless the size is changed).
For eg.
void MyDlg::CreateMemDC( CDC* pRefDC, int nWidth, int nHeight )
{
m_dcMem.CreateCompatibleDC( pRefDC );
m_bitmapMem.CreateCompatibleBitmap( pRefDC, nWidth, nHeight );
m_dcMem.SelectObject( &m_bitmapMem );
}
void MyDlg::OnInitDlg()
{
CClientDC dc( this );
CreateMemDC( &dc, 300, 200 );
}
void MyDlg::OnPaint()
{
BitBlt( pDC->m_hDC, .... .... ... , m_dcMem.m_hDC, ...... );
}
Please let me know if not clear enough.
- ns ami -
|
|
|
|
|
I think maybe I haven't explained my problem properly here...
The method you described is what I've always used before this project. But this time, instead of using GDI objects in memory, I've used GDI+ objects (which has made my offscreen drawing code a lot simpler and prettier, which was worth it). So, in my code m_pbmpMemory is a GDI+ bitmap and m_gr is a GDI+ Graphics object.
My problem is that DrawImage() is slow to the screen (the offscreen stuff isn't too bad really). I can't find a way to BitBlt from my GDI+ bitmap to the screen other than the code I posted and I was wondering if anyone else could see something I'm missing.
Hang on, I have an idea. I guess the other option would be to use GDI objects and then create the GDI+ Graphics object from that using Graphics::FromHDC() and store that to use for drawing to the offscreen bitmap. It looks like you can do it that way round, but not the other way (ie. create the Graphics object first, then get the HDC - you can only use one at a time so you need to release the HDC every time you draw to the Bitmap).
I'll go an investigate and see if that works...
|
|
|
|