|
i want to know how to delete a character in a text file. if i use '\b' or ascii 127(del), then i get some special characters in my file instead the characters getting deleted. Probably windows doesnt recoznise these characters as dos does. Is there any other way or any other character that can be used to delete charactes in a file either backwards or forwards ??? I use visual studio.net as my compiler.
Pls hlp.
Nikhil
|
|
|
|
|
1) Open (for read/write) the file read it into a CString or std:string, find the character you want to delete and then use the appropriate function call to delete it from the string, finaly move to the beginning of the file and write the string back to the file.
2) You could also just allocate a buffer larg enought to hold the entire file (+1, buffer must end w/NULL), read the data into the buffer, find the character, then use memmove function to delete it, finaly writing back to the file.
3) You could also read it into a large buffer then write it back to the file while skip the character that you want deleted.
4) (worst way of all - this is realy bad)
Open a tempory file and the origanal, read 1 character at a time from the origanal file and write it to the tempory file, when you find the character you want to delete then just do not copy it to the temporay file. Once you reach the end of the file you could copy the tempory file back to the origanal (or delete the origanal and rename the temporary with the origanal name).
Use your imagination, there are more ways to skin this cat than I count. But one way that you cann't do it is by inserting anouther character into the data stream.
Good Luck!
INTP
|
|
|
|
|
Hi,
I need to find out the free disk space ona computer on LAN , given the computer name. I need this to determine wether i can create a new database on a remote computer running SQL Server.
I am really in a fix over this.
Any help will be deeply appreciated.
Thanks in advance.
|
|
|
|
|
Hey. I can draw properly in the OnPaint function, but when I move my code over into the OnTimer function to work with dynamic data the code isn't drawing anything.. Any of you know what is the proper way to draw dynamic content in a Dialog Box ?
thanks.
|
|
|
|
|
You should do all your drawing int the OnPaint function. The OnTimer function should do as little as possible. For example you could set some flags when OnTimer is called and then invalidate the area (or whole dialog) that needs to be redrawn and let the OnPaint do its job.
In other words the OnTimer function should not be trying to draw any thing. If you draw anything outside of the OnPaint function it will be drawn over the next time OnPaint is called.
Good Luck!
INTP
|
|
|
|
|
Okay, Right now, whenever I need to redraw with new data, I call Invalidate Rect(). It's working okay except for the flickering but there's a lot of articles on codeproject that help with that, just haven't had time to read through them. Working on the network protocol right now.
Thanks
|
|
|
|
|
The flickering problem is easy to solve: just override the OnEraseBkgnd() so that it does not draw the backgound, then draw the background youself. If you are drawing every object yourself, then you could draw them first and use ExcludeClipRect() to remove them from the invalide rectangle follow by a call to Rectangle() to fill the background.
With the drawing method mentioned above you'll probably never see any flickering at all. I have used this method in multiple projects (See code from CExBitmap article at CP).
I know you probaly did not need this info yet, but I thought it help speed things along.
Good Luck!
INTP
|
|
|
|
|
I have an application where I have the listview control. I have implemented a sort, ascending and descending, which seems to work. The question I have is that I would like to implement the "sort arrow" on the column that is sorted. By "sort arrow", I am referring to the triangle that you see on the sorted column in Windows Explorer. I would like to show the "sort arrow" up (standard rightside up triangle) if sorted ascending and vice versa if sorted descending. Any ideas or code snippets that I can use?
|
|
|
|
|
Hello,
I have problems with reading a text file with 'cyrillic' or other texts encodings and producing XML from it.The text file itself should be ANSI and I read and convert the bytes using MultiByteToWideChar() to the codepage 1251 for cyrillic then I get those bytes and put it in the XML. On my computer it would work and the output XML is displayed correctly but on other people computers it won't work even though they have the codepage 1251 installed !!!! They get '?' symbols for the text when viewing with IE .
I have tried saving the XML UTF-8 and UTF-16 both failed to display it correctly.
I am using MSVC6.0 and compile with _UNICODE only but still it won't work.
Someone please give me a hint how to fix this.So, far anyone I ask is helpless...
|
|
|
|
|
|
I have an old dll developed in house a long time ago. It was part of an earlier project and was signed by verisign (the certificate has long since expired).
I'm using this in a project now but the expired signature is causing problems with initializing the application. Is there any way to cleanly remove the expired signature from the dll ? I have no information on the purchase of the certificate so renewing it or cancelling it now will be a problem.
"One of the Georges," said Psmith, "I forget which, once said that a
certain number of hours' sleep a day--I cannot recall for the moment how
many--made a man something, which for the time being has slipped my
memory."
|
|
|
|
|
I would like to paint a focus rect around the inside of my buttons, I can not figure out how to make a brush that is the text color every other pixel (like the standard windows buttons focus rect)
wWw.KruncherInc.cOm
|
|
|
|
|
Take a look at CPen you can set its style to PS_DOT
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Oh, I'm sorry, I forgot to mention that this program is all WIN32 not MFC.
wWw.KruncherInc.cOm
|
|
|
|
|
You'll need to call SetROP2() with the appropriate draw mode type then select a null brush into the DC so that Rectangle() will only draw the border of the rectangle without filling it.
You could take a look at one of the custom button drawing articles to see how it is done. Yes I know they are using MFC, but the steps are exactly the same. Since MFC DC class is just a wrapper around the Win32 function calls with some additional functionality to help avoid a few steps, you should have no problem understanding what they are doing.
Good Luck!
INTP
|
|
|
|
|
Hi!
I want a context menu when I click over my icon so I've done:
...
NOTIFYICONDATA icon;
icon.cbSize = sizeof(NOTIFYICONDATA);
icon.hWnd = hWnd;
icon.uID = Id;
icon.uFlags = NIF_MESSAGE|NIF_ICON;
icon.uCallbackMessage = WM_ICON_NOTIFY;
icon.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
icon.hIcon=LoadIcon(hInst,MAKEINTRESOURCE(Id));
Shell_NotifyIcon(NIM_ADD, &icon);
...
(WndProc)
case WM_ICON_NOTIFY:
hMenu = LoadMenu(hInst,(LPCTSTR)IDR_MENU1);
if (lParam == WM_RBUTTONDOWN)
{
GetCursorPos(&pos);
if (!SetForegroundWindow(hWnd)) return 0;
TrackPopupMenu (hMenu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON,
pos.x, pos.y, 0, hWnd, NULL);
PostMessage(hWnd, WM_NULL, 0, 0);
}
break;
I suppose i'm doing it not too well because it doesn't works.
Can anyone help me? Thanks.
|
|
|
|
|
Nobody can help me?
Thanks!
|
|
|
|
|
lillah wrote:
WM_ICON_NOTIFY
i want to know the value of WM_ICON_NOTIFY,is you put it in range of WM_USER message or not.
i have to used NotifyICondata in one of my article AT CP named ShutDown Alaram.
anyway if you don't want to search code form that here is code.Sorry but it in MFC
<br />
ON_MESSAGE(WM_USER+75,OnSystemBarMessage)<br />
m_niData.cbSize=sizeof(NOTIFYICONDATA);<br />
m_niData.hIcon=m_Icon;<br />
m_niData.hWnd=this->m_hWnd;<br />
sprintf(m_niData.szTip,"Shut Down Alarm :My Father Software inc @ 2003");<br />
m_niData.uCallbackMessage=WM_USER+75;<br />
m_niData.uFlags=NIF_ICON|NIF_MESSAGE|NIF_TIP;<br />
m_niData.uID=ID_ICONDATA;<br />
Shell_NotifyIcon(NIM_ADD,&m_niData);<br />
<br />
<br />
void DlgShutDown::OnSystemBarMessage(WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
switch(lParam)<br />
{<br />
case WM_LBUTTONDOWN:this->ShowWindow(SW_RESTORE);this->ShowWindow(SW_SHOW);bMiniShow=FALSE; break;<br />
case WM_RBUTTONDOWN:<br />
{<br />
CMenu mnu;<br />
mnu.LoadMenu(IDR_MENU1);<br />
<br />
PopUpMenu=mnu.GetSubMenu(0);<br />
<br />
SetForegroundWindow();<br />
CPoint pt;<br />
GetCursorPos(&pt);<br />
<br />
PopUpMenu->TrackPopupMenu(TPM_RIGHTALIGN,pt.x,pt.y,this);<br />
<br />
<br />
break;<br />
<br />
}<br />
}<br />
<br />
<br />
}<br />
<br />
<br />
Hope you can work it out
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi!
I define WM_ICON_NOTIFY as WM_USER+2
Basically, I do the same as you but for Win32, so I define this funtion
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
and process the message WM_ICON_NOTIFY but......I don't know why it doesn't works
I'm doing the same steps you do and the same that other do in their articles
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
HMENU hMenu, subMenu;
POINT pos;
BOOL traymsj;
hMenu = LoadMenu(hInst,(LPCTSTR)IDR_MENU1);
if (!hMenu) return 0;
switch (message)
{
case WM_ICON_NOTIFY:
if (wParam != (IDI_ICON1|IDI_ICON2)) return 0;
if (lParam == WM_RBUTTONDOWN)
{
subMenu = GetSubMenu(hMenu,0);
GetCursorPos(&pos);
if (!SetForegroundWindow(hWnd)) return 0;
TrackPopupMenu (subMenu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON, pos.x, pos.y, 0, hWnd, NULL);
PostMessage(hWnd, WM_NULL, 0, 0);
}
break;
...
|
|
|
|
|
I'm trying to draw a line on a form through a function which is in a class that I created inside another .h and .cpp file. But I cannot give it access to the main form or it's controls. Is there any way that I can pass the form into the functions of the class or a way that I can access the main form or maybe just a picturebox on the form in which I can draw too. And if so, how can I declare a temporary form / picturebox inside the class which I can then assign to the form / picturebox of the main form to?
PJ
|
|
|
|
|
you should be able to just pass the CDC device context to the external class for direct manipulation.
A bit like how the painting of a control is handled. The drawing area can be directly handled by the view, or its device context (CDC) can be passed to an external class for its own drawing mechanism.
I Dream of Absolute Zero
|
|
|
|
|
I need to use function of Math Class such as Sin(),ASin()
but i can't plase tell the way ,thank you
|
|
|
|
|
"#include <math.h>"
will let you use most common math functions. sin, cos and stuff like that.
|
|
|
|
|
What Math class?
Which language are you working on??
In C/C++, you can #include "math.h" and use functions like sin(...), cos(...), asin(...), log(...) etc.
ARSALAN MALIK
|
|
|
|
|
tell me what the problem in c++ i see your problem i mean what the problem in maths class plz write and send me my address is talharehman@dr.com ok
|
|
|
|