|
This could be a very simple question but could anyone out there help me. I was hoping that there was an easy way to get a program to draw a line from one set of (x, y) coordinates to another set of (x, y) coordinates. I have looked everywhere but have had no joy so please help.
|
|
|
|
|
::MoveTo(..);
::LineTo(..);
Look up these in MSDN!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Docking windows in Win32 without MFC is what I'm currently
coding. I'm doing it this way:
I have Dock bars, which are just frameless gray child windows. The frame
window consists of four of such dock bars and a client window. The frame
window also resizes all these five windows, e.g. the dockbar at the left is
stretched along the y-axis, the dockbar at the upper side is stretched along
the x-axis etc.
Now there are dock windows. These can dock on a dockbar or float. When
floating, they get a toolwindow frame and a popup style. If, for example, I
wanna dock a toolbar, I can do two things:
a) derive a toolbar class from the dockwindow one, or
b) i can make the toolbar a child of the dockwindow.
DockBar itself is responsible for repositioning and/or resizing the docked
dock windows.
To disable the (de)activation of floating windows and the main window, I use James Brown's method (see http://freespace.virgin.net/james.brown7/tuts/docking1.htm). Do you have any suggestions how to solve the docking problem better?
|
|
|
|
|
I have been trying hard to script a code to search all the *.com and *.exe files in a hard disk recursively and list them in a list box.Till now i have been sucessful partially.Like...right now the program works in a limited way. if u search for all files (*.*) then it will find them even in the subdirectories recursively , but for any other type (*.exe or *.com etc) it will search only the given directory not the subdirectories.So if u can edit this code so that it searches *.com and *.exe at the SAME TIME recursively through out the hard disk and list them in a list box..
Thank You!
void CSearchDlg::OnBfind()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_cGet.ResetContent();
m_cGet.AddString(m_cDrive);
_chdir(m_cDrive);//"C:\\progra~1//Accessories");
m_ccomment.SetWindowText("Searching...");
//m_csearch.SetWindowText("");
GetDlgItem(IDC_BFIND)->EnableWindow(FALSE);
GetDlgItem(IDC_BSTOP)->EnableWindow(TRUE);
//GetDlgItem(IDC_BCONNECT)->EnableWindow(TRUE);
//GetDlgItem(IDC_BCONNECT)->EnableWindow(TRUE);
// search for the filename
SearchDirectory();
// announce when done
m_ccomment.SetWindowText( "Files found");
MessageBox("Done Searching");
GetDlgItem(IDC_BFIND)->EnableWindow(TRUE);
}
void CSearchDlg::SearchDirectory()
{
struct _finddata_t filestruct;
long hnd;
char buffer[_MAX_PATH];
int i=0;
// set _findfirst to find everthing
hnd = _findfirst("*",&filestruct);
// if handle fails, drive is empty...
if((hnd == -1)) return;
// get first entity on drive - check if it's a directory
if(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_DIRECTORY)
{
// if so, change to that directory and recursively call SearchDirectory
if(!(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_HIDDEN))
if(*filestruct.name != '.')
{
_chdir(filestruct.name);
SearchDirectory();
// go back up one directory level
_chdir("..");
}
}
else
{
// if it's not a directory and it matches what you want...
if(!stricmp(filestruct.name,m_cFile))
{
// output the filename with path to debugger
_getcwd(buffer,_MAX_PATH);
strcat(buffer,"\\");
strcat(buffer,filestruct.name);
strcat(buffer,"\r\n");
//OutputDebugString(buffer);
m_cGet.AddString(buffer);
}
}
while(!(_findnext(hnd,&filestruct)))
{
if(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_DIRECTORY )
{
if( !(::GetFileAttributes(filestruct.name) & FILE_ATTRIBUTE_HIDDEN))
if(*filestruct.name != '.')
{
_chdir(filestruct.name);
SearchDirectory();
_chdir("..");
}
}
else
{
if(!stricmp(filestruct.name,m_cFile))
{
_getcwd(buffer,_MAX_PATH);
// extn=::GetFileExt(filestruct.name);
strcat(buffer,"\\");
strcat(buffer,filestruct.name);
strcat(buffer,"\r\n");
//OutputDebugString(buffer);
m_cGet.AddString(buffer);
}
}
}
//m_ctotalfile.AddString((LPCTSTR)i);
_findclose(hnd);
}
|
|
|
|
|
Sorry,I'm very lazy to read all your code,but one time I had the same problem,and solve it in this way:
I use (*.*) for search,so it search in subfolders too,and each file you get,check the last three character of its name and see if it is "exe" or "com",then if it is true show it in listbox.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
When you search only for .exe or .com files, directories will not be found. And so directories will also not be scanned recursively.
Try the following: search for ALL files ("*") and then check if the extension of a found file is .exe or .com. If it is, add it to the listbox. If not, check for directory, and if it isn't a directory, simply skip it.
This will find directories AND .exe/.com files
|
|
|
|
|
hi friendd
i cant read ur code completlly soo
try this
CFileFind oFind;
bool ret=oFind.FindFirstFile("ur Drive\path\*.*");
while(ret)
{
ret=oFind.FindNextFile();
//the n check it is dotz . or ..
if(oFind.IsDots()) continue;
check is it directory
// if(oFind.IsDirectory())
{
then call this function recursivly
}
//else it is a file then get the file name
by usin
GetFileName()/GetFilePath() function search the last three chars if it is a exe or com
then add the name in to a list box /anywhere u want
GetFileName() will give the file name and GetFilePath() wil give the complete path
}
}
try it now..!!
Renjith
Hai Friends me from Pandalam..and i think there is a sofware behind everything...
so enjoy with the codes...
|
|
|
|
|
How can I read data from a text file line after line, as 'Line Input' function in Visual Basic ?
I want to use CFile object or anything else.
Appstmd
|
|
|
|
|
ifstream has a GetLine function, I believe. It's part of iostreams, and unlike CFile does not require MFC, or even a Windows platform.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
CStdioFile f1;
if( !f1.Open( filepath, CFile::modeRead | CFile::typeText ) )
{
MessageBox("Could not open file");
return;
}
CString str1;
while(f1.ReadString(str1))
{
}
f1.Close()
Regards,
Nish
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|
I draw some graph in the 'CView' with 'CDC', but I can't save it to file.
|
|
|
|
|
I use Imgsource from Chris Losinger
http://www.smalleranimals.com/isource.htm
saved me many hours
Happy programming!!
|
|
|
|
|
Read the FAQ.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I have compiled a single-document program and overload 'OnSize ' of CMainFrame,below is my code.
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
CRect rect;
GetWindowRect(&rect);
if(rect.Height() < 200)
rect.bottom = rect.top + 200;
if(rect.Width() < 200)
rect.right = rect.left + 200;
MoveWindow(rect);
}
Though the length and width of the window are all greater than 200, it twinkles very much. How can I keep it from twinkling?
Still has , and how to make maximize , minimalize and the restore of window and system menu lose efficacy ?
|
|
|
|
|
I would try doing this in the OnSizing message instead. OnSize occurs after the window has been sized. OnSizing occurs right before the window will be resized.
If the effect that you are trying to create is to make sure that a window can be no less than a certain size, then you will actually want to handle the WM_GETMINMAXINFO message. This will allow you to set the max and min dimensions of you window. Then when the user tries to resize the window, they will not be able to drag the border past the dimensions that you have specified.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
How can I access a CD at the track level in Win32? I'm trying to access Redbook Audio information.
|
|
|
|
|
I have 2 text boxes, one for inputting numbers and the other is a read only box that reads in that number. Depending on whether that number is even or odd, the read only box changes its background to green(even) or red(odd). However, the text inside the read only box then flickers when it's displayed. How do I fix this?
This is what I have done:
HBRUSH CSmallDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CEdit * pEditReadOnly = (CEdit *)GetDlgItem(IDC_EDIT_DISPLAY); //read only
HWND hWndReadOnly = pEditReadOnly->GetSafeHwnd();
if(m_brush)
DeleteObject(m_brush);
CString input_value;
m_INPUT_BOX_VALUE.GetWindowText(input_value); //get value from input
m_DISPLAY_BOX_VALUE.SetWindowText(input_value); //read box displays it
long int number = atoi(input_value); //convert input_value to integer
if(nCtlColor == CTLCOLOR_STATIC &&
hWndReadOnly == pWnd->GetSafeHwnd())
{
pDC->SetBkMode(TRANSPARENT);
if (number % 2 == 0) { // if even change background to green
m_brush = CreateSolidBrush(RGB(0,255,0)); // green background
pDC->SetTextColor(RGB(0,0,0)); // black text
}
else { // else it is odd (red)
m_brush = CreateSolidBrush(RGB(255,0,0)); // red background
pDC->SetTextColor(RGB(255,255,255)); // white text
}
hbr = m_brush;
}
return hbr;
}
|
|
|
|
|
Please use the <pre> tag when posting code samples; it's nice to see indentation
I don't know the answer off-hand, but i might try
pDC->SetBkMode(OPAQUE);
pDC->SetBkColor(RGB(0,255,0));
instead of
pDC->SetBkMode(TRANSPARENT);
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
That doesn't get rid of the flicker.
Thanks though.
|
|
|
|
|
Are you setting the text each time you change the back color?
Nish
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|
Ignore the last post please.
I didnt read the head post. Just read the 3rd one and replied without thinking
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|
Nish [BusterBoy] wrote:
Ignore the last post please.
I didnt read the head post. Just read the 3rd one and replied without thinking
? i'm pretty sure you were right. It took me a while to figure it out though. If you're that good not thinking, then you must be scary when you think.
You'r apostrophe bug's me.
|
|
|
|
|
Shog9 wrote:
? i'm pretty sure you were right.
Yes
I was right.
He is setting the text each time
Man I am really absent minded today
Nish
If I am awake and my eyes are closed, it does not necessarily mean that I am thinking of naked women.
|
|
|
|
|
Nish [BusterBoy] wrote:
Man I am really absent minded today
Bah! It's Sunday. And Daylight Savings Time. With a double-whammy like that, who can blame you?
You'r apostrophe bug's me.
|
|
|
|
|
Ok, totally didn't pick up on this the first time through, but - You are setting the text for the control each time OnCtlColor() is called. Remember, OnCtlColor() is called for more than just static text controls - your edit box is triggering it also. A much better way (and one which will probably eliminate your flicker) is to synch the text within an EN_CHANGE handler for the edit box, and set only the color within the OnCtlColor() function.
You'r apostrophe bug's me.
|
|
|
|