|
I assume your system has a regular operating system, with a file system and such. So:
Why would you read a file using Assembly if you plan on handling the data in C anyway???
If there is no compelling reason to use Assembly, then don't. If there is, use it where you
have to, file I/O would not be the first area that comes to mind.
BTW If you need to support a special device, write a device driver for it; and do that in
C or C++ too, not Assembly.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
well what i am trying to do is write a mini os... so using assembly or c to implement the i/o is the only solution to the problem and the main reason for this os something else so i am not going on to write these features myself.
what i am actually trying to do is read the bitmap file and display it.
if there is a pure c solution to it... its going to work i wont mind... as long as it works
thanks for the reply.
Umer
|
|
|
|
|
Member 1950781 wrote: what i am trying to do is write a mini os
At the OS level you'll need to manipulate the hardware directly.
A good place to start is the specs for the hardware your OS will run on.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i m running it in the virtual pc
i am able to get it to print text on the screen but i cant figure out a way to do these io functions
|
|
|
|
|
i figured i will have to go through a hell lot of trouble of implementing an ide driver to do the file system io
anyways thanks a lot guys
|
|
|
|
|
Hi,
you can write most of an operating system in a high-level language (C, C++, Pascal, whatever).
Having pointers and not relying on a virtual machine (as in Java and .NET) makes it easier.
I did a couple of OSses in C, for different microprocessors.
The only thing you will need assembly code for, is the actual task switch code, where
you unload the CPU state for one task/process and load the next.
you can read an image file in any language you choose; all it takes is reading the file
as binary data, and interpreting its content. I wrote C# image viewers for most of the popular
image file formats.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello,
I'm writing an MFC application that produces printed documents. I am using MFC's native printing support to draw to a CScrollView, through my own implementation of OnDraw(CDC* pDC) .
This works nicely. I can see what I've drawn in the ScrollView, and can scroll by compensating for the offset in co-ordinates in my OnDraw ( I haven't forgotten to *not* compensate when printing; pDC->IsPrinting() is called).
However, I cannot figure out why (through inference from an example app, and reading the documentation available) my "drawing" won't print or appear in print preview.
void CReportView::OnPrint(CDC *pDC, CPrintInfo *pInfo)
{
UNREFERENCED_PARAMETER(pInfo);
CReportView::OnDraw(pDC); // my own implementation of OnDraw
CScrollView::OnPrint(pDC,pInfo);
}
I would have thought that by passing the device context that the framework provides to OnPrint to OnDraw, that the printing device context would have been drawn to, but this doesn't work.
What should I do?
Thanks,
Sternocera
|
|
|
|
|
Here's a quick sample to plop into a new CScrollView doc/view app to see if the results are consistent using print preview. It's more of a WYSIWYG approach and simplifies printing because it uses the same drawing code to print that is used for the screen. Try this out in a new project then adapt what you need to your application.
NOTE: This was previous post of mine describing the print paging mechanism to someone but it demonstrates general printing. I hope it helps.
//CDocument members...
// Header file .h
protected:
CSize m_DocSize;
// Implementation file .cpp
CSize CYourDoc::GetDocSize() const
{
return m_DocSize;
}
CYourDoc::CYourDoc()
{
// TODO: add one-time construction code here
m_DocSize=CSize(2000,2800);
}
//CScrollView members...
// Header file .h
private:
int m_nPage;
// Implementation file .cpp
CYourView::CYourView()
{
// TODO: add construction code here
SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values
m_nPage=1;
}
/***************************************
NOTE: The pInfo parameter is uncommented
****************************************/
void CYourView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* pInfo)
{
// TODO: add extra initialization before printing
pInfo->SetMaxPage(3);
}
void CYourView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
m_nPage=pInfo->m_nCurPage;
CScrollView::OnPrint(pDC, pInfo);
}
void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC);
// TODO: Add your specialized code here and/or call the base class
// Set up the DC for the current scale factor
int nExtentX;
int nExtentY;
CSize sizeDoc;
CRect rectClient;
pDC->SetMapMode(MM_ISOTROPIC);
// Get pertinent rectangle data
GetClientRect(&rectClient);
sizeDoc=GetDocument()->GetDocSize();
sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments
pDC->SetWindowExt(sizeDoc); // Window extent is size of document
// Calculate viewport extent
nExtentX=rectClient.Width();
nExtentY=(int)((nExtentX*sizeDoc.cy)/(sizeDoc.cx));
// What kind of device context do we have?
if (pDC->IsPrinting()==TRUE) {
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES));
} else {
// Context is for screen
pDC->SetViewportExt(nExtentX,nExtentY);
}
}
void CYourView::ResetScrollBars()
{
CSize sizeDoc;
CClientDC dc(this);
this->OnPrepareDC(&dc); // Update the device context
sizeDoc=GetDocument()->GetDocSize();
dc.LPtoDP(&sizeDoc); // Logical to device
this->SetScrollSizes(MM_TEXT,sizeDoc); // Update scrollbars
}
void CYourView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ResetScrollBars();
}
void CYourView::OnDraw(CDC* pDC)
{
CYourDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CSize sizeDoc=pDoc->GetDocSize();
CRect rectOutline(0,0,sizeDoc.cx,sizeDoc.cy);
rectOutline.DeflateRect(10,10); // Ensure we can see it
LOGFONT logFont={0};
memcpy(logFont.lfFaceName,"Arial",6);
logFont.lfHeight=300;
CFont font;
font.CreateFontIndirect(&logFont);
CFont* pOldFont=pDC->SelectObject(&font);
CBrush* pOldBrush=(CBrush*)pDC->SelectStockObject(NULL_BRUSH);
CString sMessage;
sMessage.Format("You can add code to center the printout later\nPage %d",m_nPage);
pDC->DrawText(sMessage,&rectOutline,DT_CENTER|DT_WORDBREAK);
pDC->Rectangle(&rectOutline);
pDC->SelectObject(pOldFont);
pDC->SelectObject(pOldBrush);
}
|
|
|
|
|
Holle,
I would like to implement a system using Browser/Server architecture.
Server end will run Linux whereas clinet end will run Windows.
What computer programing language will be suitable for this application development.
Thanks
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Don't cross post. It is considered rude.
cy163@hotmail.com wrote: What computer programing language will be suitable for this application development.
Probably php if you are going to have the server on a linux box...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi.
I was wondering if someone could tell me how to change the icon of the exe for the program? Is there was a way I could just do a define to use the bitmap or icon I want so that I can change it anytime?
Thanks in advance!
Stan the man
|
|
|
|
|
Do you mean the icon shown in the Windows Explorer windows?
If so, the system uses the icon resource with the lowest ID
by default (e.g. 1).
For the application while it's running, you can use the
WM_SETICON message (CWnd::SetIcon() in MFC).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can use of LoadIcon and then SetIcon?
|
|
|
|
|
dear friend
what problem is following calculation? thanks
here gbest is a 3x4 array
for (int i =0;i<10;i++)
{
for (int j = 0;j<3;j++)
{
for (int k = 0;k<4;k++)
v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]);
x[i][j][k] = x[i][j][k] + v[i][j][k];
}
}
computer showed me:
error C2064: term does not evaluate to a function taking 1 arguments
error C2112: '-' : pointer subtraction requires integral or pointer operand
Li Zhiyuan
5/10/2006
|
|
|
|
|
if gbest is an array, shouldn't it have the dimensions at its side?
v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]);
shouldn't it be:
v[i][j][k] = w*v[i][j][k] + c1*rand()*(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()*(gbest[i][j][k]-x[i][j][k]);
Hope this helps...
|
|
|
|
|
I guess pbestArray is a pointer to the array, so I think
pbestArray[i][j][k]-x[i][j][k]
should be
(*pbestArray)[i][j][k]-x[i][j][k]
And , as Joan Murt said, you should add "*" between rand() and ...(something after it).
May you good luck
============
Einstein
Seeing is believing.
|
|
|
|
|
It flicks only in one case.
When another window(A) cover the window(B) in my app, then I minimize A and the mouse cursor becomes in the client of B, then the B flicks. Here is the code in OnMouseMove , how to solve the problem? Thanks.
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
Point pt(point.x,point.y);
m_pcs->DrawCom(m_pMemGraphics);
m_pcs->DrawCtl(m_pcs->GetSelDev(pt),m_pMemGraphics);
Invalidate(FALSE);
CDialog::OnMouseMove(nFlags, point);
}
|
|
|
|
|
Why are you calling Invalidate() there?
What does your WM_MOUSEMOVE handler do?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I check if the mouse cursor is on some area, then draw a bound box if it is.
|
|
|
|
|
You should be able to just draw to a client DC without
having to go through the WM_PAINT message.
If you must use Invalidate() there, maybe following it
with an immediate call to UpdateWindow() will help...so
there's no delay before the relulting WM_PAINT message is
processed.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
How do you understand the comments from Bjarne about exception specification?
--------------------
(section 14.6.1 Checking Exception Specifications)
The way to think about exception-specifications is to assume that a function will throw any exception it can. The rules for compile-time checking exception-specifications outlaw easily detected absurdities.
--------------------
thanks in advance,
George
|
|
|
|
|
Compile-time checking means you know every situations, and you rule the world. Such as:
int a = 3;
if(a != 3) {
throw Err();
}
But the spirit of exception is "exception", which means you only know to handle "some" rules, but you won't know "the rest" part. Such as:
try {
bool b = The_API_from_some_DLL();
}
Maxwell Chen
|
|
|
|
|
Thanks Maxwell,
Your reply is clear and my question is almost answered. Bjarne's comment "outlaw easily detected absurdities" means?
regards,
George
|
|
|
|
|
George_George wrote: Bjarne's comment "outlaw easily detected absurdities" means?
Meaning: When you expect the enemy to enter your fort from the front gate (compile-time [easily detected absurdities] ), they might enter from tunnel or from the sky.
Maxwell Chen
|
|
|
|