|
JoeSox wrote:
Where can I find a table for colors in hex?
You do not need to supply the rgb values in hex.
Using MS Paint you can get the rgb value to use in your app.
Paul
|
|
|
|
|
ah, thank you!!
Later,
JoeSox
|
|
|
|
|
|
Hi All,
I just wanted to get some opinions on the best and/or simplest way to access a MS Access DB using VC++ without MFC.
Thanks,
Paul
|
|
|
|
|
OLEDB using ATL support classes (CSession, CCommand and so on).
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Hello everyone, i have a small problem trying to guess how to add a small icon in listbox.
I am pure API programmer so i think there may be some problems with that (?)
I just set a text on index 1 in listbox, and also i would like to put beside the text a small icon
representing some action.
Please help me to solve it..
|
|
|
|
|
I'm having a problem trying to get a custom control to respond to OnPaint(). I followed Chris Maunders' Creating Custom Controls tutorial to create the control, great tutorial. Now I am trying to get it to paint the control a different color. I'm using this custom control as part of a tetris clone I am writing. The project is dialog based and this custom control is what I'd like to use for the 'game board'. To test I am using buttons on the dialog where the custom control resides. Just to make sure everything is communicating correctly I used some AfxMessageBox calls to verify. And all the right functions are being called, I just cant get it to paint. The following is in my OnPaint() for the custom control class:
thanks for any help,
paul
void CGameBoard::OnPaint() <br />
{<br />
CPaintDC dc(this);
CRect rect;<br />
<br />
GetWindowRect(rect);<br />
ScreenToClient(&rect);<br />
<br />
dc.FillSolidRect(rect,RGB(35,30,100));<br />
<br />
}
I first call a Paint() function. It calls Invalidate then calls OnPaint()
void CGameBoard::Paint()<br />
{<br />
Invalidate();<br />
OnPaint();
}
|
|
|
|
|
hi. is there any Simple Code to play a Wav file from a Resource ?
thanks
|
|
|
|
|
PlaySound(MAKEINTRESOURCE(IDS_SOUND), :confused:, SND_RESOURCE | SND_ASYNC);
You need to experiment a bit with the parameters, but SND_RESOURCE is the way to go
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
i set : #include "MMSYSTEM.H"
and i use : PlaySound("c:\\sample.wav", NULL , SND_RESOURCE | SND_ASYNC);
but this error occured :
ERROR LNK2019 : unresolved external Symbol___imp___PlaySound@12 refrenced in function : public :int__thiscall CTestView::.....
|
|
|
|
|
put winmm.lib into your linker settings or use this line in your stdafx.h file: #pragma comment(lib, winmm)
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Winmm.lib?
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
I have a irregular shaped dialog created using regions. How do i go about change this region dynamically?? I tried creating the new region and use SetWindowRgn(...) again but it returns FALSE. Any ideas?
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
i never use the function, here is a "guess".
1. try to set a new region which is smaller than previous one.
if works:
2. call SetWindowPos to make sure square window is larger than new region first, then call SetWindowRgn
hope see ur testing result soon.
includeh10
|
|
|
|
|
I'm trying to open a drive, by specifying the lpFileName argument to be of the format "\\.\<drivename>:" in CreateFile. But when i use ReadFile to read from the disk, i get an error, number 87 which means invalid parameter, anyone know what's wrong?
char test[32];
HANDLE hDrive = CreateFile("\\\\.\\H:", GENERIC_READ, FILE_SHARE_WRITE , NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwBytesRead;
ReadFile(hDrive, &test, 32, &dwBytesRead, NULL);
CloseHandle(hDrive);
Thanks all!
-Rune SVendsen
|
|
|
|
|
Redeemer-dk wrote:
anyone know what's wrong?
Yes, and so does the MSDN documentation:
Note that all I/O buffers must be sector aligned (aligned on addresses in memory that are integer multiples of the volume's sector size), even if the disk device is opened without the FILE_FLAG_NO_BUFFERING flag.
|
|
|
|
|
I program an app that uses a treeCtrl, and I use the tv_item::lParam save an address of an item in std::list. Code like this:
std::list<MyStruct> items;
....
std::list<MyStruct>::iterator pCur = items.begin();
TVM_INSERTITEM tvi;
tvi.item.mask = TVIF_TEXT | TVIF_PARAM...
tvi.item.lParam = &(*pCur);
....
TreeView_InsertItem(hTree, &tvi);
....
when I retrive an item of the tree and its MyStruct:
MyStruct* pMyStruct;
TV_ITEM item;
item.mask = TVIF_TEXT|TVIF_PARAM...
TreeView_GetItem(hTree, &item);
pMyStruct = (MyStruct*)item.lParam;
Now, the pMyStruct is not equal the &(*pCur) above.
How can I prohibit STL alter its items' addresses?
|
|
|
|
|
hmm, just wild guess, looking on the code excerpt, I would expect the problem lays in a definition:
std::list<MyStruct> items;
the stl actually creates a copy of your item, because this definition says keep a list of MyStruct instances. And as stl works, they keep a copy of your structures. Benefit is that the instances will be destroyed together with the list.
Better then is the definition like this:
std::list<MyStruct*> items;
this will keep the pointers, so they should remain the same (their content). Disadvantage of this method - when releasing the list, only the pointers will be cleared, but not the structure instances (possible memory leaks)
or even better is to use some kind of auto_ptr (I use CAutoPtr from ATL), this have a benefit, that all the structures are released when the list is cleared, but no whole-structure-copying overhead.
|
|
|
|
|
I found some code on MSDN which loads jpegs and put it into my program with a little modification. I have a jpeg loaded into dialog which is part of a tab control. From the resource editor I drew the outline of the picture and gave it a border and I thought that the actual painting should be done through a WM_CTLCOLORSTATIC message. The picture loads fine with some exceptions. When I switch tabs the picture disappears and never comes back until I reopen the dialog. If I click outside the window to hide it under some other program I might be running (eg. Iexplorer) and bring it back the picture is gone for good also. Here is the code:
<br />
case WM_CTLCOLORSTATIC:<br />
iStaticWindow = GetWindowLong( (HWND) lParam, GWL_ID );<br />
<br />
switch(iStaticWindow)<br />
{<br />
case IDC_PICTURE:<br />
hDC = GetDC(hwndPicture);<br />
<br />
if (gpPicture)<br />
{<br />
long hmWidth;<br />
long hmHeight;<br />
<br />
gpPicture->get_Width(&hmWidth);<br />
gpPicture->get_Height(&hmHeight);<br />
<br />
int nWidth = MulDiv(hmWidth, GetDeviceCaps(hDC, LOGPIXELSX), HIMETRIC_INCH);<br />
int nHeight = MulDiv(hmHeight, GetDeviceCaps(hDC, LOGPIXELSY), HIMETRIC_INCH);<br />
<br />
RECT rcDlg;<br />
GetClientRect(hDlg, &rcDlg);<br />
<br />
RECT rc;<br />
GetWindowRect(hwndPicture, &rc);<br />
<br />
MoveWindow(hwndPicture, rcDlg.right - (nWidth + 4), 11,<br />
nWidth + 3, nHeight + 3, TRUE);<br />
<br />
gpPicture->Render(hDC, 0, 0, nWidth, nHeight, 0, hmHeight, hmWidth, -hmHeight, &rc);<br />
<br />
}<br />
<br />
ReleaseDC(hwndPicture, hDC);<br />
<br />
return TRUE;<br />
<br />
case IDC_CONTROL1:<br />
case IDC_CONTROL2:<br />
SetTextColor( (HDC) wParam, RGB(0, 0, 0));<br />
SetBkColor( (HDC) wParam, RGB(170, 170, 213) );<br />
<br />
return (BOOL) hControlBrush;<br />
After playing around with it I noticed that I don't have these problems if I remove the switch statement but I need that in order to take care of the other static controls. I also noticed that if I get rid of the MoveWindow function then the picture never gets drawn in the first place. One last peculiarity to mention: In the resource editor if I don't use a modal or a static frame for the picture window (which I chose enhanced metafile) then the picture gets drawn at the top left corner of the screen (entirely outside the window). If anyone can help me I would appreciate it. This also includes sending me to places to learn about painting because it is obvious I know nothing about it. Thanks in advance.
|
|
|
|
|
I'm not master of painting, but I would stick with the painting code to the WM_PAINT message - this you receive allways, when something needs to be repainted (part of window, whole window...). Don't know if and how to handle it is with dialogs, but normally in windows everything needs to be repainted againg and again when something is drawn over it (another window). For that is there the WM_PAINT message (one of the parameters is the rectangle needed to be repainted, then you do not need to repaint the whole window allways)
For reference of the GDI and other window stuff, there is a good book from Charles Petzold (ISBN:157231995X). Haven't read it personally (as I am not working with GUI much), but the references are quite good.
|
|
|
|
|
Hi all,
I have a vc problem which i am unable to think of a solution. so can anyone help ??
i have a data type as follow:
typedef struct complextag
{
double dRe;
double dIm;
} COMPLEX;
and i have 3 classes which need this data type. (main class, class A and class B). The main class will have to interact with class A and class B and pass a COMPLEX variable to them.
Hence i have put the "typedef struct complextag" in the class A and class B header. I also include the class A and class B header in class main.
However when i compile the program, vc complaint of this "error C2011: 'complextag': 'struct type redefinition'
is there a way to solve this prob ?? or is there a way to make the COMPLEX data type to be universal like "int" or "float" ???
Thank you very much for the kind attention.
|
|
|
|
|
One way ( I am sure there are others ) is to wrap the declaration in an #define macro. That way it will not get redeclared.
#ifndef I_ALREADY_DEFINED_THIS_STRUCT
#define I_ALREADY_DEFINED_THIS_STRUCT
typedef struct complextag
{
double dRe;
double dIm;
} COMPLEX;
#endif
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Put the type definition in a header file (just in case), and add #pragma once at the top of it.
|
|
|
|
|
Hi PJ Arends and .S.Rod.
Really thanx a lot for your help !!
I have used the suggested macro and it works !!
|
|
|
|
|
hi. i am writing a project in MFC and i am using GDI+ in this project. when i Execute my project.exe in another Operating System it says : mfc40...dll Not Found. the joke is that my project Size is only 300kb and the Size of all Dll that needed in project is 2 mb
is there anyway to include these Dlls in project to get rid of them or somthing to recude the Dlls Size ?
thanks.
-=Ehsan-de-Burge=-
|
|
|
|