|
Hi,
I don't have a message map for my rich edit so this the code for OnPaint for the Parent
Dialog
After I streamin my data the data is displayed with a thin blue background this backgrounds surrounds just this text so I when I streamin 2 lines there is blue background white line
following it.
next line of text surrounded by the blue background I am trying to get rid of blue background when I inserted the OnPaint the entire rich edit is covered up
afx_msg void Show_storage::OnPaint()
{
CPaintDC richdc(Myrich);
richdc.SetBkColor(RGB(255,255,255));
}
|
|
|
|
|
Like I said before, you cannot just paint into a control as and when you like. You must only do it in its OnPaint member function.
|
|
|
|
|
(this is partly a rant, because it seems to be something really easy to do, but the framework makes it really hard to achieve).
I need to be able to change the background color of a CMFCButton when certain conditions happen in our application.
According to the documentation, I could use the method CMFCButton::SetFaceColor (Sets the background color for the button text); but this will get overridden (sp?) by the visual manager drawing method (CMFCBaseVisualManager::DrawPushButton ) and will have not effect.
Our application is under control of a CMFCVisualManager theme; so all controls are drawn to respect the current theme ( we want to have themes in our application).
There is a static method in CMFCButton to disable themes for ALL CMFCButtons; so that is a little bit overkill.
I could set the CMFCButton flag m_bDontUseWinXPTheme to TRUE (which will disable the theme for that particular button (I would need to inherit from CMFCButton) But that will change the look of the button (and if I want to keep some of the look, I would have to draw all of it manually).
Any insights, tips or hints on what would be the best way to change the background color of a CMFCButton without having to re-invent the wheel?
Thanks.
Max.
I'd rather be phishing!
|
|
|
|
|
Alas, think your only solution is to derive your own button from the MFC one and change the OnDraw() method (think that's what the draw method is called, going off memory). I had to do this for a set of buttons that reflected status on their color. It's not terribly hard to do once you've done it once.
|
|
|
|
|
Thanks,
That was just too easy...
I'd rather be phishing!
|
|
|
|
|
|
Thanks,
That was just too easy...
I'd rather be phishing!
|
|
|
|
|
I hate to say this, but I never cease to be amazed at the number of questions I manage to answer just by looking at the documentation.
|
|
|
|
|
I know.
When I originally looked at OnDraw, I did not want to use it because I expected to have to redraw everything (inner, outer, fill, text and theme support)
But it ended up to look something like:
OnDrawn(...)
{
if (condition)
pDC->FillRect(...);
else
pDC->FillRect(...);
__super::OnDraw(...)
}
I'd rather be phishing!
|
|
|
|
|
hi
i have grid view in asp.net project .and this grid view have different information in each page how can i use tool-tip in each cell
thanks
|
|
|
|
|
"i have grid view in asp.net"
Are you sure that are you on the right forum ? 
|
|
|
|
|
well after hours of work I finally managed to combine 2 scripts that i worked on
The purpse of the code is to get an adress of the folder that includes different kind of files
and the code needs to open the folder that is near it (2 folders in 1 folder)
and compair each time 2 files 1 is the compairer and the second is on of the files that is in the path in argv[1]
but every time after I combined the code and tried to fix it theres a triggered breakpoint
If anyone could tell me how to solve the problems in my script I will be very greatfull
the part where it doesnt work is at the while in the function at the end
here is my code:
http://pastebin.com/C5BYSNYK
modified 24-May-15 11:10am.
|
|
|
|
|
You still have lines of code of the form:
char* entrenceToTheFolderBefore = (char*)malloc(NULL);
which, as I explained will lead to problems: you will either get strange results, or a program crash. If you are going to store data in the buffer returned from malloc then you must allocate enough space for the data you are going to copy into it. Anything less will cause your program to overwite other variables.
|
|
|
|
|
i cant allocate because it gives me garbage every time i add 1
or simply try to allocate
can you rewrite it to make more sence ?
|
|
|
|
|
OK, let us say that you have a path ("C:\Users\Noname\Documents\Test") in argv[1], and you now want to inspect a subdirectory called "images":
int argvSize = strlen(argv[1]); int mallocSize = argvSize + strlen(subdir) + 1 + 1;
char* newPath = (char*)malloc(mallocSize);
strcpy(newPath, argv[1]); strcat(newPath, "\\"); strcat(newPath, subdir);
|
|
|
|
|
for some odd reason it still adds me junk letters that 1 last null
int temp3 = location + 1;
char* entrenceToTheFolderBefore = (char*)malloc(sizeof(char)*temp3);
for (int i = 0; i < location; i++)
{
entrenceToTheFolderBefore[i] = argv[1][i];
}
puts(entrenceToTheFolderBefore);
is there any way we could communicate like through skype ? i have only 2 hours left before the handout
|
|
|
|
|
Yes because you are using the count from location to do the copy, which is the length of the string, and so will not include the null character. Use the code sample I gave you which makes use of standard library functions that will ensure your copied data is correctly structured.
a random user wrote: is there any way we could communicate like through skype ? Sorry, I do this in my own time and at my own speed. I will not be available much longer today.
|
|
|
|
|
Ok then..
I did what you told me but the results are still the same
The problem is in the second while
and in entrenceToTheFolderBefore 1 more bit as null gives me =@$&!%
int temp3 = location + 1;
char* entrenceToTheFolderBefore = (char*)malloc(sizeof(char)*temp3);
for (int i = 0; i < location; i++)
{
entrenceToTheFolderBefore[i] = argv[1][i];
}
puts(entrenceToTheFolderBefore);
location2 = location;
while (location2 != argvSize)
{
location2++;
UnwantedName[countLoop] = argv[1][location2]; // problem
countLoop++;
}
OtherDir = opendir(entrenceToTheFolderBefore);
while (OtherEnt = readdir(OtherDir)) ////UnwatedName = C2_Mid_Anti-Virus_Project.zip
{
if ((strcmp(OtherEnt->d_name, UnwantedName) != 0) && (strcmp(OtherEnt->d_name, ".") != 0) && (strcmp(OtherEnt->d_name, "..") != 0)) //problem
{
strcpy(InfectedFolderPath, entrenceToTheFolderBefore);
strcat(InfectedFolderPath, "/");
strcat(InfectedFolderPath, OtherEnt->d_name);
puts(InfectedFolderPath);
}
}
closedir(OtherDir);
modified 24-May-15 13:30pm.
|
|
|
|
|
a random user wrote: I did what you told me but the results are still the same That's because you did not do what I told you. You are still copying your path strings based on strlen rather than strlen +1. And you seem to be creating too many variables, most of which are just duplicates of existing items. This may well be what is causing you confusion.
|
|
|
|
|
i did try that but the extra byte always when i do puts() adds alot of random letters
int temp4 = argvSize - location; //temp4 = 30
char* UnwantedName = (char*)malloc(sizeof(char)*temp4);
int temp3 = location+1; //temp3 = 24
char* entrenceToTheFolderBefore = (char*)malloc(sizeof(char)*temp3);
for (int i = 0; i < location; i++)
{
entrenceToTheFolderBefore[i] = argv[1][i];
}
puts(entrenceToTheFolderBefore); // ---> C:/Users/win7/Desktop/1=(alotof ascii characters
|
|
|
|
|
That is because you keep doing the same thing wrong. You need to stop and think, and reread all my posts that explain how to do it properly. Especially look closely at the sample code I posted yesterday
|
|
|
|
|
i did do waht you told me i expended the string by 1
but that 1 byte is messing up my code
even trying using strcat just makes it worse I stopped and read all of ur recent psots but i have nothign that comes in mind that could help me
im sorry for giving you a hard time here but it is hard for me as it is
would you please fix the code to show me what you mean?
|
|
|
|
|
|
I did calculate the bytes and the characters as i needed it needs to be 24 bytes
when at the last code i posted you can see that until i reach to the point that is /1 its 23 bytes
the + 1 is the one i added so it will be the end of the string
|
|
|
|
|
well.. im trying to open a folder with an unknown number of programs
using argv and argc through the cmd to the adress of the folder
i need to use the dirent.h and maybe the FILE struct
to open the files
the code needs to open each file and search the text within (it has mp3 signatures etc) in a binary way and search through it with a second file that the text inside of it is not in any place in there
in other words i need to spot if the second file's signature is nto repeatign anywhere on the other files
this is the far that i got but im stuck
can anyone help me?
#include <stdio.h>
#include <stdlib.h>
#include "dirent.h"
int main(int argc, char** argv){
int count = 0, size = 0;
int sizes[3];
FILE *log = fopen("C:\\Users\\win7\\Desktop\\1\\C2_Mid_Anti-Virus_Project.zip\\AntiVirusLog.txt", "wt");
DIR *dir;
struct dirent *ent;
int found = 0;
dir = opendir(argv[1]);
while ((ent = readdir(dir)))
{
count++;
sizes[0] = strlen(argv[1]);
sizes[1] = 2;
sizes[2] = strlen(ent->d_name);
size += sizes[0] + sizes[1] + sizes[2] + 1;
char* string = (char*)malloc(sizeof(char)*size);
_flushall();
strcpy(string,argv[1]);
strcat(string, "\\");
strcat(string, ent->d_name);
FILE* youtube = fopen (string, "rb");
if (youtube != NULL)
{
print("success \n");
}
puts(ent->d_name);
}
fclose(log);
closedir(dir);
return 0;
}
|
|
|
|