|
Hello all,
I have a fully functional Visual C++ .NET console application that draws an ASCII character map at run-time in a DOS window. How can I start a window and draw the map real-time to that window as opposed to the DOS window? I have very little experience with Windows graphics so any advice would be greatly appreciated on how to start the window, draw to it, etc ...
By the way, the map I need to draw is simply a grid with different squares in the grid having different colors.
Thanks guys and girls.
|
|
|
|
|
Hi Friend
Write graphical functions under OnPaint() function
eg:
CPaintDC dc;
dc.Rectangle(0,0,100,100);
CDC/CPaintDC is used for graphical function
Please use MSDN and search for CDC class
regards
KK
|
|
|
|
|
I'm starting a project using splitter windows and the problem is that the compiler returns this ."error C2039: 'classCDados' : is not a member of 'CDados'" when i atach this class in CSplitterWnd::CreateView();
This class (CDados) is derived from CFormView and the project from CView.
The question is: Is it because of the #include staments or are the classes beeing created the wrong way?
<br />
#include "stdafx.h"<br />
<br />
#include "Fdlg.h"<br />
#include "FdlgView.h"
#include "Janela.h"
#include "JanelaB.h"
#include "Dados.h"
<br />
#include "MainFrm.h"<br />
Thank you for the help.
|
|
|
|
|
jpMFC wrote: 'classCDados' : is not a member of 'CDados'"
Are you sure this is not a typo ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think this has something to do with DECLARE_DYNAMIC or DECLARE_DYNCREATE.
Just take a look.
I can tell this because of "classCDados". The above two macros does this like this "class##CDados". So they are concatenated at runtime to give "classCDados".
Just make sure.
Take note:
DECLARE_DYNAMIC must have a corresponding IMPLEMENT_DYNAMIC.
DECLARE_DYNCREATE must have a corresponding IMPLEMENT_DYNCREATE.
I think either of them could be missing.
Just a thought.
Owner Drawn
--Nothing special
|
|
|
|
|
I need a VC++ way [Windows MFC] to click a 'Pause' button and interrupt a long running actuarial computation.
ActuaryChuck
|
|
|
|
|
Put the "long running actuarial computation" in a separate thread so that the primary thread (the one that owns the Pause button) remains responsive. See here for more.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello!
I would like to install .inf modem files in windows. I've searched MSDN but i've found only modem .inf structure, nothing about installing them. I already read some Setup API functions ( SetupDi* ) but I'm not sure those are the ones i need. If so, which of them are needed to do this? or how to do this? I really don't have any ideas
i hope you can help me,
grizz
|
|
|
|
|
it's really important for me nobody?
|
|
|
|
|
Hi,
I am storing some data into the list and updating the map in STL. Next time when i tried to get the data from the list based on bstr key, I am getting wrong data. So i want to make change the key from bstr to any easy data type (say long). can you please help me out so that i can use simple key for searching and store the data in stl.
Thank
|
|
|
|
|
|
I already seen these link however it would't resolve my issue.I can't use the MFC class.
|
|
|
|
|
what about char * or STL Strings ?
'g'
|
|
|
|
|
Tried after converting to TCHAR * however it is still showing wrong data.
|
|
|
|
|
how about posting some code so I/others can take a look - its a bit hard working blind !!
'g'
|
|
|
|
|
itkid wrote: Next time when i tried to get the data from the list based on bstr key, I am getting wrong data.
Sounds to me like your code is wrong. Have you tried using a wrapper like _bstr_t ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am trying to show a gradient on the screen... the program shows the gradient and then erases it - I can't understand why. I have included the entire program - ran it under win 98, Visual C++ 6 - Can anyone help me?
#include <windows.h>
HINSTANCE hInst;
MSG msg;
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
HWND MainWnd;
WNDCLASS wc;
int mx,my;
hInst=hInstance;
wc.style=0;
wc.lpfnWndProc=(WNDPROC) MainWndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH) GetStockObject(BLACK_BRUSH);
wc.lpszMenuName=0;
wc.lpszClassName="Black";
if(!RegisterClass(&wc)) return 1;
mx=GetSystemMetrics(SM_CXSCREEN);
my=GetSystemMetrics(SM_CYSCREEN);
MainWnd=CreateWindowEx(0,"Black","Black Screen",WS_POPUP,
0,0,mx,my,0,0,hInstance,0);
if(!MainWnd) return 1;
ShowWindow(MainWnd,SW_RESTORE);
while(GetMessage(&msg,0,0,0))
{
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
HDC h1;
HPEN hp1;
HPEN hpa[64];
int i,mx,my,in;
switch (umsg){
case WM_NCPAINT:
mx=GetSystemMetrics(SM_CXSCREEN);
my=GetSystemMetrics(SM_CYSCREEN);
mx--;my--;
h1=GetWindowDC(hwnd);
hp1=CreatePen( PS_SOLID, 1, RGB(0,0,0));
SelectObject(h1, hp1);
for(i=0;i<=my;i++)
{
MoveToEx(h1,0,i,NULL);
LineTo(h1,mx,i);
LineTo(h1,mx-1,i);
}
ReleaseDC( hwnd, h1);
return TRUE;
case WM_PAINT:
mx=GetSystemMetrics(SM_CXSCREEN);
my=GetSystemMetrics(SM_CYSCREEN);
mx--;my--;
h1=GetWindowDC(hwnd);
for(i=0;i<=63;i++)
hpa[i]=CreatePen( PS_SOLID, 1, RGB(0,i*4,0));
for(i=0;i<=my;i++)
{
in=i*63/(my+1);
SelectObject(h1, hpa[in]);
MoveToEx(h1,0,i,NULL);
LineTo(h1,mx,i);
LineTo(h1,mx-1,i);
}
ReleaseDC( hwnd, h1);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
default:
return (DefWindowProc(hwnd,umsg,wParam,lParam));
}
}
D. Emmanuel
|
|
|
|
|
Got it... Works if GetWindowDC and ReleaseDC are replaced by BeginPaint and EndPaint
D. Emmanuel
|
|
|
|
|
Hi,
Am doing a project in vc++ win32.
How do I create a binary file using CreateFile() function. I dont see any attributes regarding that.
Thanks a lot in advance.
|
|
|
|
|
At the level of CreateFile, ALL files are binary, as your choice to write is WriteFile, which takes a pointer to a sequence of bytes.
If you want to make a Windows-compatible ASCII text file, just put a CRLF at the end of a 'line' of text, and Voila! instant text file.
|
|
|
|
|
Great! Thanks for your reply...
Also having another question. I want to create a new file if file does not exist, but if the file already exists then I want to append to the existing file. How do I do it.
I am using
hOp = CreateFile("RECORDOUT.TXT", // open OUT.TXT
GENERIC_WRITE, // open for writing
0, // do not share
NULL, // no security
OPEN_ALWAYS, // open or create
FILE_ATTRIBUTE_NORMAL, // normal file
NULL);
but it is always overwriting instead of appending.
Thanks.
|
|
|
|
|
You need to set the file pointer to the end of the file before writing to it if the file already exists. Otherwise, each time you open the file, the 'writing' will start at the very beginning of the file.
This will set file pointer to end of file, so you can 'append':
SetFilePointer(hOp, 0, NULL, FILE_END);
|
|
|
|
|
I tried to add scroll bar to the child window in a MDI.
In the mother window I modify code as below:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style =WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL;////Mewly added
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
It works well.
However in the child windows.
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
///////////Mewly added///////////////////////////
cs.style =WS_CHILD|WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL;
//////////////////////////////////////////////////////////////////////////
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
The scroll bar will appear when running the program, however it doesn't function. I can't scroll the child window at all.
I also tried the method recommended by MSDN---- "derive a new class from CMDIChildWnd and replace all references to CMDIChildWnd in your project with references to the new class." The scroll bar wont even come out. Where did I make mistake?
Anybody can help me with the simple question?
Hello, Everybody!!!
|
|
|
|
|
Hi All,
I am getting this error while bulding the project.
LINK : fatal error LNK1104: cannot open file "msxfs.lib"
And when I give path of this lib file in project settings, it is giving me 42 errors and I am sure that my code doesn't have any error.
Please tell me how to fix this error.
Thanks in advance
Preeti9
|
|
|
|
|
I think the linker would disagree with you.
However, in the interest of fairness, how about posting some of the errors so the more-experienced of us might be able to help you out
|
|
|
|
|