- int SaveRegion(HRGN hRgn,char *name);
- HRGN LoadRegion(char *name);
-
-
-
- ////////////////////////////////////////////////////
- int SaveRegion(HRGN hRgn,char *name)
- {
-
- int iSize = GetRegionData(hRgn, sizeof(RGNDATA), NULL);
-
- // Allocate memory to hold the region data
- RGNDATA* pData = (RGNDATA*)calloc(iSize, 1);
- pData->rdh.dwSize = iSize;
-
- // Get the region data
- int iSize2 = GetRegionData(hRgn, iSize, pData);
- // Sanity check
- if (iSize != iSize2) return 0; //
- // ::MessageBox(NULL, L"Something wrong with GetRegionData...", L"Error", MB_ICONERROR);
-
- // Save region data to a file
- FILE* f = fopen(name, "wb");
- fwrite((char*)pData, sizeof(char), iSize, f);
- fclose(f);
-
- // Free allocated memory
- free(pData);
-
- // Delete our region
- //DeleteObject(hRgn);
- return 1;
- }
-
-
- ////////////////////////////////////////
- HRGN LoadRegion(char *name)
- {
- // Open file to read region data
- FILE* f = fopen(name, "rb");
- // Get size of the file
- fseek(f, 0, SEEK_END);
- int iSize = ftell(f);
- fseek(f, 0, SEEK_SET);
- // Allocate memory to hold the region data
- RGNDATA* pData = (RGNDATA*)calloc(iSize, 1);
- // Read region data from file
- fread((char*)pData, sizeof(char), iSize, f);
- fclose(f);
-
- // Create region from loaded region data
- HRGN hRgn = ExtCreateRegion(NULL, iSize, pData);
-
-
- // As a demonstration, set the loaded region as window region
- // so it is visually clear that it got loaded correctly.
- //::SetWindowRgn(g_hWnd, hRgn, TRUE);
- // Free allocated memory
- free(pData);
-
- return hRgn;
- }
- /////////////////////////////////////////////////
-
int SaveRegion(HRGN hRgn,char *name);
HRGN LoadRegion(char *name);
////////////////////////////////////////////////////
int SaveRegion(HRGN hRgn,char *name)
{
int iSize = GetRegionData(hRgn, sizeof(RGNDATA), NULL);
// Allocate memory to hold the region data
RGNDATA* pData = (RGNDATA*)calloc(iSize, 1);
pData->rdh.dwSize = iSize;
// Get the region data
int iSize2 = GetRegionData(hRgn, iSize, pData);
// Sanity check
if (iSize != iSize2) return 0; //
// ::MessageBox(NULL, L"Something wrong with GetRegionData...", L"Error", MB_ICONERROR);
// Save region data to a file
FILE* f = fopen(name, "wb");
fwrite((char*)pData, sizeof(char), iSize, f);
fclose(f);
// Free allocated memory
free(pData);
// Delete our region
//DeleteObject(hRgn);
return 1;
}
////////////////////////////////////////
HRGN LoadRegion(char *name)
{
// Open file to read region data
FILE* f = fopen(name, "rb");
// Get size of the file
fseek(f, 0, SEEK_END);
int iSize = ftell(f);
fseek(f, 0, SEEK_SET);
// Allocate memory to hold the region data
RGNDATA* pData = (RGNDATA*)calloc(iSize, 1);
// Read region data from file
fread((char*)pData, sizeof(char), iSize, f);
fclose(f);
// Create region from loaded region data
HRGN hRgn = ExtCreateRegion(NULL, iSize, pData);
// As a demonstration, set the loaded region as window region
// so it is visually clear that it got loaded correctly.
//::SetWindowRgn(g_hWnd, hRgn, TRUE);
// Free allocated memory
free(pData);
return hRgn;
}
/////////////////////////////////////////////////